BrunoLM
BrunoLM

Reputation: 100361

How to escape Japanese characters?

I have the following string

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

Is there a way to escape these characters so it would be converted to

"滅殺豪波動"

Is there some way to do it?

Upvotes: 0

Views: 641

Answers (1)

Clicktricity
Clicktricity

Reputation: 4209

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();
}

Upvotes: 4

Related Questions