开发者

How to escape Japanese characters?

开发者 https://www.devze.com 2023-01-18 16:21 出处:网络
I have the following string \"Messatsu Gou Hadou (滅殺豪波動)\" Is there a way to escape the开发者_如何学JAVAse characters so it would be converted to

I have the following string

"Messatsu Gou Hadou (滅殺豪波動)"

Is there a way to escape the开发者_如何学JAVAse characters so it would be converted to

"滅殺豪波動"

Is there some way to do it?


You could write a function like this:

public static string EscapeString(string s)
{
    StringBuilder sb = new StringBuilder();

    foreach (char c in s)
    {
                int i = (int)c;
                if (i < 32 || i > 126)
                {
                    sb.AppendFormat("&#{0};", i);
                }
                else
                {
                    sb.Append(c);
                }

    }

    return sb.ToString();
}
0

精彩评论

暂无评论...
验证码 换一张
取 消