Multibyte support on Windows, Phobos vs Tango, which is right?

yidabu yidabu.nospam at gmail.com
Wed Apr 9 16:14:34 PDT 2008


Multibyte support on Windows, Phobos vs Tango, which is right ?

1  Phobos has toMBSz function for Converts the UTF-8 string s into a null-terminated string in a Windows
   8-bit character set.
   like this:
   
    char* toMBSz(char[] s, uint codePage = 0)
    {
        // Only need to do this if any chars have the high bit set
        foreach (char c; s)
        {
            if (c >= 0x80)
            {
                //do convert
            }
        }
        return std.string.toStringz(s);
    }
   
   Tango has not this function, is it necessary ?
   
2  Is toMBSz(char[]) same as char[] ~ '\0' ?

    for example, FileCreateA
    
    Phobos way:
    char[] name;
    CreateFileA(toMBSz(name) ...)
    
    Tango way:
    char[] name;
    FileCreateA( name ~ '\0' ...)
    
    Is toMBSz(char[]) always same as char[] ~ '\0' ?
    Is toMBSz("Chinese汉语"c) always same as "Chinese汉语"c ~ '\0' ?
    
    If Phobos is right, too many bugs in Tango, Tango use char[] ~ '\0' everywhere for calling A version Windows API!
    
    
3   Phobos zip vs Tango Zip

    I used Phobos zip module, it works fine, a trick is zip.ArchiveMember.name should be locale encode for multibyte environment.
    
    Tango way:
    char[][] files = [r"D:\Chinese中文.txt"];
    createArchive(r"test.zip", Method.Deflate, files);
    
    cause Exception: 
    object.Exception: cannot encode character "20013" in codepage 437.

    Tango seems lacks multibyte support on Windows, 
    and have not run special unittests for multibyte environment on Windows before publish a new vesion.

    
    

-- 
yidabu <yidabu.nospam at gmail.com>
D语言 中文支持(D Chinese Support)
http://www.d-programming-language-china.org/
http://bbs.d-programming-language-china.org/
http://dwin.d-programming-language-china.org/
http://scite4d.d-programming-language-china.org/



More information about the Digitalmars-d mailing list