Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
431 views
in Technique[技术] by (71.8m points)

json - c# Save korean string to file, not utf form string


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

What you probably want here is - right at the start:

opt.Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping;

(obviously don't change this constantly - set it once only; if a different usage needs different options: use a different options object)

This leaves the Name unescaped, rather than escaping it in the JSON. From there, you can then encode the string any way you like.

You should also note that the name UnsafeRelaxedJsonEscaping suggests that there may be scenarios in which this is undesirable, so: it would be worth trying to read the documentation on UnsafeRelaxedJsonEscaping to understand when and why this is.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...