[英]Unicode into symbol C++
I want to convert my unicode string (unic) which is "U+XXXX" to "\\uxxxx" so I could print a symbol, yet I get the following error: incomplete universal character name \\u|\u003c/i>我想将“U+XXXX”的 unicode 字符串 (unic) 转换为“\\uxxxx”,以便我可以打印一个符号,但出现以下错误:不完整的通用字符名称 \\u|\u003c/b>
How would I make a working symbol code "\\uxxxx" from having a string of "U+xxxx"?我如何从具有“U+xxxx”的字符串中制作工作符号代码“\\uxxxx”?
My code:我的代码:
string unic = "U+xxxx";
unic.substr(2);
string symb="\u";
unic.insert(0, symb);
cout<<unic<<endl;
In addition to the backslash issue already pointed, you must assign unic.substr(2)
to a variable because it is not a destructive operation :除了已经指出的反斜杠问题之外,您必须将unic.substr(2)
分配给变量,因为它不是破坏性操作:
string unic = "U+xxxx";
unic = unic.substr(2);
string symb="\\u";
unic.insert(0, symb);
cout<<unic<<endl;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.