How to handle Unicode contained in json C #,

Source: Internet
Author: User

How to handle Unicode contained in json C #,

Public static class StringExtension {# region unicode Character escape // <summary> // convert any escape character in the input string. For example: unicode \ u8be5 // </summary> /// <param name = "str"> </param> /// <returns> </returns> public static string unicodeDencode (this string str) {if (string. isNullOrWhiteSpace (str) return str; return Regex. unescape (str );} /// <summary> /// unicode encode the string /// </summary> /// <param name = "str"> </param> // <returns> </returns> public static string UnicodeEncode (this string str) {if (string. isNull OrWhiteSpace (str) return str; StringBuilder strResult = new StringBuilder (); if (! String. isNullOrEmpty (str) {for (int I = 0; I <str. length; I ++) {strResult. append ("\ u"); strResult. append (int) str [I]). toString ("x4");} return strResult. toString () ;}# endregion}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.