[Win32utils-devel] Fwd: win32-clipboard and Unicode zero bytes
Park Heesob
phasis at nownuri.net
Fri Feb 3 01:03:11 EST 2006
Hi,
On Thu, 02 Feb 2006 17:28:59 -0700, Daniel Berger wrote
> Berger, Daniel wrote:
>
> >>-----Original Message-----
> >>From: win32utils-devel-bounces at rubyforge.org
> >>[mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of
> >>Park Heesob
> >>Sent: Thursday, February 02, 2006 5:07 AM
> >>To: Development and ideas for win32utils projects
> >>Subject: Re: [Win32utils-devel] Fwd: win32-clipboard and
> >>Unicode zero bytes
> >>
> >>
> >
> ><snip>
> >
> >
> >
> >>Here is some patches of clipboard.c
> >>
> >>Line 70:
> >> hMem = GlobalAlloc(GHND, strlen(data) + sizeof(TCHAR*));
> >>to
> >> hMem = GlobalAlloc(GHND, RSTRING(rbData)->len + sizeof(TCHAR*));
> >>
> >>Line 75:
> >> strcpy((TCHAR *)GlobalLock(hMem), data);
> >>to
> >> memcpy((TCHAR *)GlobalLock(hMem), data, RSTRING(rbData)->len);
> >>
> >>HTH,
> >>
> >>Park Heesob
> >>
> >>
> >
> >Works great, thanks! Please commit.
> >
> >Dan
> >
> Nevermind, I'll commit it now and put out a new release shortly.
>
> Here's a question for everyone, though - in the age of Unicode, is
> strcpy obsolete? Should we always use memcpy?
>
> Dan
Refer to http://www.tbray.org/ongoing/When/200x/2003/04/26/UTF
http://www.i18nguy.com/unicode/c-unicode.html
http://www.marin.clara.net/tips/unicode_tips.htm
You can use strcpy and strlen in case of UTF-8, but cannot use in UTF-16, UTF-32 etc.
In Unicode environment, you should use wcscpy and wcslen instead of strcpy and strlen.
Regards,
Park Heesob
More information about the win32utils-devel
mailing list