Re: Why use the unicode version of the api?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



hello again
i've use the ansi version in a dbcs korean system with a string in korean
and sames to functions good. Can someone know what are the problems with
this api 32 unicode funcion? why is necesary to use them in an aplication
programming?
Thanks in advanced
Gustavo Echevarria

"Thorsten Albers" <albersRE@xxxxxxxxxxxxxxxxxxx> escribió en el mensaje
news:01c5eba4$e2b1e380$b38ee684@xxxxxxxxxxx
> Gustavo Echevarria <g.echevarria@#REMOVETHIS#lantek.es> schrieb im Beitrag
> <#UMiMt56FHA.2036@xxxxxxxxxxxxxxxxxxxx>...
>> i have a question regarding the two different versions of the win32 apis
> of
>> some functions. For example RegQueryValueExW and RegQueryValueExA. Can i
> use
>> any of them in a chinesse operation system?. What problems can i have in
>> those dbcs systems?
>
> With the "W" version you will get the Unicode text. With the "A" version
> you will get the Unicode text converted to ANSI text. But: ANSI is a
> character encoding supporting only 255 characters (1 byte per character),
> Unicode uses 2 bytes per character thus supporting at least 65536
> characters (with the so-called surrogates it is more then 65536). For some
> Unicode codepoint ranges the 256 characters are sufficient, but for most
> of
> them they are not since most writing systems are using more then 256
> characters.
> On a japanese and chinese version of windows the ANSI functions do support
> DBCS ANSI strings with a mixture of one or two bytes per character
> (handled
> by the use of so-called lead bytes). But AFAIK this isn't valid for other
> writing systems that are using more then 256 characters, i.e. DBCS with
> "A"
> functions is restricted to japanese and chinese. So, if not used
> explicitely for japanese or chinese writing system strings, using the "A"
> version would result in information loss.
> And DCBS ANSI strings are not easy to handle, Unicode strings clearly are
> the better choice. DCBS is the past, Unicode is the future...
> If you want to use DCBS in your application, of course you should use the
> "A" function versions, or, IMHO better, you should use the "W" versions
> and
> map the Unicode strings with MultiByteToWideChar()/WideCharToMultiByte()
> from or to DBCS ANSI strings.
>
> --
> ----------------------------------------------------------------------
> THORSTEN ALBERS Universität Freiburg
> albers@
> uni-freiburg.de
> ----------------------------------------------------------------------
>



.



Relevant Pages

  • Re: VB6 generates faulty exe code: UDT passed from VB6 to DLL
    ... Especially around DBCS characters. ... Example 2 takes 20 bytes in Unicode but 10 bytes in ANSI so doesn't have this problem: ... In ANSI each byte is a TCHAR but a TCHAR is not an entire character. ... experiments, if the fixed strings was a standalone variable, VB6 allocated enough bytes for then entire converted string. ...
    (microsoft.public.vb.bugs)
  • Re: VB6 ANSI to Unicode conversion wrong with fixed-length strings in structures
    ... > I have a Fortran DLL that returns a structure containing fixed-length ... > strings to a VB6 program. ... > returning Chinese characters. ... I can only think that VB's implicit ANSI ...
    (microsoft.public.vb.bugs)
  • Re: VB6 ANSI to Unicode conversion wrong with fixed-length strings in structures
    ... work for all DBCS characters. ... The non-VB DLL always uses nul-terminated strings, ... You may also wish to consider passing the native Unicode around, if your DLL ... I can only think that VB's implicit ANSI ...
    (microsoft.public.vb.bugs)
  • Re: VB6 ANSI to Unicode conversion wrong with fixed-length strings in structures
    ... This problem happens with any code page that includes more than just single-byte characters, it happens even if the DLL is written in VC++6 or even if the DLL is built into Windows, and it happens even if a later version of VB is used. ... A partial workaround, if your code page only has characters of length two bytes or less, is to specify a string length double what you're actually going to use, and then only store strings up to half of the specified length. ... Behind the scenes VB creates a copy of the structure with ANSI strings of 20 bytes. ...
    (microsoft.public.vb.bugs)
  • Re: VB6 generates faulty exe code: UDT passed from VB6 to DLL
    ... In VB6 a fixed-length string ... > sure to use at most half of that number of characters minus 1. ... > executable code and/or VB runtime library reserve space for an ANSI string ... Especially around DBCS ...
    (microsoft.public.vb.bugs)