Archived Forum Post

Index of archived forum posts

Question:

C++ socket, utf-32 encoding the same as utf-32be encoding

Feb 16 '17 at 14:05

Here is my sample code:

int main( int argc, char* argv[] ) {

    CkSocket sock;
    bool success;
    success = sock.UnlockComponent( "Anything for 30-day trial" );
    if (success != true) {
        std::cout << sock.lastErrorText() << "\r\n";
        return 1;
    }

    success = sock.Connect("localhost", 23, false, 20000);
    Sleep( 1000 );
    sock.put_StringCharset( "ansi" );
    sock.SendString( "abcd" );
    Sleep( 1000 );
    sock.put_StringCharset( "utf-8" );
    sock.SendString( "abcd" );
    Sleep( 1000 );
    sock.put_StringCharset( "unicode" );
    sock.SendString( "abcd" );
    Sleep( 1000 );
    sock.put_StringCharset( "unicodefffe" );
    sock.SendString( "abcd" );
    Sleep( 1000 );
    sock.put_StringCharset( "ansi" );
    sock.SendString( "abcd" );
    Sleep( 1000 );
    sock.put_StringCharset( "utf-32" );
    sock.SendString( "abcd" );
    Sleep( 1000 );
    sock.put_StringCharset( "utf-32be" );
    sock.SendString( "abcd" );
    Sleep( 1000 );
}

The messages received by the server (running echotool.exe from https://github.com/PavelBansky/EchoTool) are

Client 127.0.0.1:54760 accepted at 4:07:08 PM
4:07:09 PM received [abcd]
4:07:10 PM received [abcd]
4:07:11 PM received [a b c d ]
4:07:12 PM received [ a b c d]
4:07:13 PM received [abcd]
4:07:14 PM received [a   b   c   d   ]
4:07:15 PM received [a   b   c   d   ]

These all look fine, except the last two are the same. The last one (utf-32be) should be

[   a   b   c   d]

I'm using I'm using v9.5.0.66 (x86-vc12) from 2/2/2017 to test.


Answer

Here are the new builds:

http://chilkatdownload.com/prerelease/chilkat-9.5.0-x86-vc12.zip
http://chilkatdownload.com/prerelease/chilkat-9.5.0-x86_64-vc12.zip
http://chilkatdownload.com/prerelease/chilkat-9.5.0-x86-vc12_xp.zip
http://chilkatdownload.com/prerelease/chilkat-9.5.0-x86_64-vc12_xp.zip


Answer

Interesting... I did some digging and found a discrepancy w/ code pages (12000 vs 65005). I'm making a fix and will send you a new build ASAP..