It might be a stupid question, but ... Say I have a Stringlike 4e59that represents a special unicode character. How can I add \uthis symbol to the beginning so that it displays correctly? I tried the simplest solution:
String
4e59
\u
String str = "4e59"; System.out.println("\\u"+str);
And a few more options, what am I missing?
\ u is parsed at compile time, not runtime, so just prefixing your line with "\ u" will not work.
You can use Integer.parseInt for this parsing at runtime:
System.out.println((char)Integer.parseInt("4e59", 16));
, , , , "\u" : "\uXXXX" javac ( , ). , "\u", .
"\u"
"\uXXXX"
\uXXXX , . , Java:
\uXXXX
int i; \u0069\u006E\u0074 \u0069\u003B
You need to convert it to char:
char
System.out.println((char) Integer.parseInt("4e59", 16));
Source: https://habr.com/ru/post/1720036/More articles:Creating a Windows Windows Service on Windows Mobile 6.x - .netHow to use Xcode performance tools with a static library project? - iphoneHow to display free iPhone memory? and how to free up iPhone memory? - memory-managementCombine additional executables with py2exe - pythonContext menus and NavigateTo in Blend / SketchFlow - xamlHow to filter by the number of associations? - sqlSpringJUnit4ClassRunner initializes beans for each test? - javaSQLite: объединить SELECT и DELETE в одном выражении - sqlHow can I use openssl in Qt or CQA for symbian? - qtHow to programmatically check if ASP.NET is allowed in IIS6 Web Services Extensions? - iis-6All Articles