Prev: Remote reboot
Next: Delete Printer
From: Kellie Fitton on 12 Sep 2005 16:08 Hi, Just for debugging purpose, try to define the szText as a WCHAR, and use the API MultiByteToWideChar() to convert the fileName into the UNICODE format, before calling the API CreateFileW(). http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/unicode_17si.asp Hope these information helps, Kellie.
From: Floptimize on 12 Sep 2005 16:27 That was the first thing I tried, however when converting to UTF8 for example the call the CreateFile failed with a bad path error meaning it couldn't even understand the path to the file, let alone the filename. There doesn't seem to be any other CodePage options that I could try. Any suggestions?
From: Lucian Wischik on 12 Sep 2005 16:48 "Floptimize" <bikermike(a)gmail.com> wrote: >That was the first thing I tried, however when converting to UTF8 for >example the call the CreateFile failed with a bad path error meaning it >couldn't even understand the path to the file, let alone the filename. >There doesn't seem to be any other CodePage options that I could try. Show us your UTF8 source code. -- Lucian
From: Bob Hairgrove on 12 Sep 2005 17:07 On 12 Sep 2005 12:30:38 -0700, "Floptimize" <bikermike(a)gmail.com> wrote: >Thanks for reply, I am in the process of experimenting with >FindFirstFile/Next. Good suggestion. > >Regarding the alt-sequence suggestion, well unfortunately, that's >exactly how I entered the filename to begin with into the VC6.0 editor. > >I'll followup shortly. > >Thanks Of course, none of this stuff will work on Windows 95/98/ME without additional Unicode libraries as explained in the MSDN documentation to every API function. I am assuming that you have Windows NT/2000/XP here. The big problem is, none of the Windows Unicode API functions can deal with UTF-8, and UTF-8 is rapidly becoming established in the real world as the de facto Unicode standard. They (the API functions) all expect 16-bit wide wchar_t arrays (wchar_t is 32-bit on most Unix systems, though ... but then you wouldn't have to worry about the Win32 API functions working correctly <g>). If you are entering Unicode text directly into your code, as opposed to getting it from a resource DLL, you'll therefore need to define it directly as an array of wchar_t in numeric notation because your compiler can't handle Unicode text in the source code. Do you have an editor that can handle Unicode, for example UltraEdit? I have successfully entered Russian text into my C++ source code as an array of wchar_t, e.g.: const wchar_t MyRussianText [] = { &x0417, &x0434, &x0440, &x0430, &x0432, &x0441, &x0442, &x0432, &x0443, &x0439, &x0442, &x0435, &x002C, &x0020, &x0442, &x043E, &x0432, &x0430, &x0440, &x0438, &x0449, &x0021, 0 }; You can do this in UltraEdit by following these steps: (a) Create the text somehow, you can use the Windows "character map" program to enter it one character at a time, then copy & paste into the editor. If you are using UltraEdit, make sure that you have set your new file to be a Unicode file (not UTF-8, but the other variety offered). Your text should display correctly if you have chosen a font which supports your range of Unicode characters (e.g. Courier, Arial or Times New Roman should all work); (b) Change the view to hex edit (in UltraEdit, it's located under the Edit menu, or you can press CTRL-H). (c) Select the bytes you want to use in your code (probably without the first two bytes == BOM, if any). From the Edit menu, select "Hex Copy selected view". (d) Open a new file with ASCII editing, and paste the selected hex view into it. Turn on column mode and get rid of the extra stuff (file offsets in left column, text gibberish in right column, leave the hex bytes in the middle). (e) Staying in column mode, cut and paste the high bytes where they should belong and add the "&x" bits and commas to make them look like the above example. Don't forget to add a trailing null byte, though! Now you can pass "MyRussianText" to Windows API functions which expect an LPCTSTR (or WCHAR const *) parameter. You'll want to add some kind of "#ifdef UNICODE" macro to bypass the wchar_t type definition if you compile an ANSI version. -- Bob Hairgrove NoSpamPlease(a)Home.com
From: Bob Hairgrove on 12 Sep 2005 17:14
On Mon, 12 Sep 2005 23:07:09 +0200, Bob Hairgrove <invalid(a)bigfoot.com> wrote: >Of course, none of this stuff will work on Windows 95/98/ME without >additional Unicode libraries as explained in the MSDN documentation to >every API function. I am assuming that you have Windows NT/2000/XP >here. I just saw your original message where you state that you have Windows XP Pro, so this should work OK. -- Bob Hairgrove NoSpamPlease(a)Home.com |