locked
WCF Service RestFul Service with Unicode support RRS feed

  • Question

  • My WCF RestFul service pulls data from MS SQL Unicode (NVARCHAR) columns. The data can be displayed only if it is in english otherwise I have problem. I m using JSON.

    Any help would be appreciated.

    Thank you

    Monday, February 24, 2014 2:12 PM

Answers

  • by simply adding prefix @ resolved the issue!
    • Marked as answer by Raj Krish Monday, March 3, 2014 9:02 AM
    Monday, March 3, 2014 9:02 AM

All replies

  • Hi,

    Since you have set the sql column to NVARCHAR, then it should support many other language. Please first try to check it in the sql server side:
    http://stackoverflow.com/questions/3682156/how-to-show-eastern-letterchinese-character-on-sql-server-sql-reporting-servic .

    Then I am not sure if you want to use the Non-unicode, if so, please try to check the following:

    It is highly recommended to use unicode whenever possible. Non-unicode applications will have a difficult time to interoperate with other applications. Unicode can represent almost any characters in the world, including Chinese Simplified/Traditional.

    But if you have to use non-unicode, since you're working on a REST application, you can manually parse the request body, and do anything you want. For example, you can read the request body into a byte array, create an Encoding object using the encoding you want, and use Encoding.GetString to read the byte array into a unicode string. String objects in .NET always use unicode. After you get the string, if you want to deserialize it into a CLR object, you can use DataContractJsonSerializer.ReadObject.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, February 25, 2014 3:46 AM
  • I tried converting Unicode to UTF8 using Encoding ... still no respite!

    Appreciate your response.

    Thursday, February 27, 2014 5:24 AM
  • by simply adding prefix @ resolved the issue!
    • Marked as answer by Raj Krish Monday, March 3, 2014 9:02 AM
    Monday, March 3, 2014 9:02 AM