简体   繁体   English

Android / Java-将转义的控制字符转换为转义的Unicode字符

[英]Android/Java - convert escaped control characters to escaped Unicode character

In an Android app, I need to convert this... 在Android应用中,我需要对此进行转换...

"Hello,\nWorld!"

...into this... ...到这个...

"Hello,\u000dWorld!"

...in order to spit this "converted" string to a remote server through JSON. ...以便通过JSON将“转换后的”字符串吐到远程服务器。

How do I accomplish that, preferably WITHOUT the use of anything but the "standard" Java/Android API? 如何做到这一点,最好不要使用除“标准” Java / Android API之外的任何东西?

您可以使用String.replace(char, char)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM