开发者

How to escape Japanese characters?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜