dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Character encoding across OS

  1. #1
    Join Date
    Jan 2006
    Posts
    384

    Character encoding across OS

    There is a client side component on Windows and a Server side component on Solaris, both built using C++.
    The client side component is an MBCS build application and sends character data over TCP/IP to the server side.
    With the understanding that the client side is executing in a code page 932 environment, and the user enters Japanese characters (which will be SHIFTJIS encoded), will the SOLARIS server be able to receive the characters (assuming the locale the server side is running on is ja_JP.PCK) and use the printf() command to correctly display the Japanese characters on the server side ?

    Is there a difference in the encoding values of the character set as represented by SJIS (CP 932) on the Windows side and SJIS(represented by ja_JP.PCK) on the Solaris side ?

    For designing such cross platform apps, would UTF-8 be the best way to go ? If so, why (wont there be the problem of BOM supported on some platforms and not supported in others etc. )

  2. #2
    Join Date
    Nov 2003
    Posts
    1,902

    Re: Character encoding across OS

    >> Is there a difference in the encoding values of the character set as represented by SJIS ... and SJIS ...?
    Shift JIS is an encoding standard. So if both sides claim it, it's safe to assume they are the same. And since it uses single-byte storage, it can be safely transmitted over TCP/IP or stored in a file without worrying about endianess.

    >> ... and use the printf() command to correctly display the Japanese characters on the server side ?
    If the current locale supports the encoding (and there's font support), then yes.
    Call setlocale(LC_ALL, "") to use the user's locale settings. The default "C" locale does not support Shift JIS, so setlocale must be called.

    >> For designing such cross platform apps, would UTF-8 be the best way to go ?
    For new development, probably. You don't need a BOM for TCP transmission. Let the user store their text in whatever encoding they want - with or without a BOM.

    gg

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)