1

When writing for technical audiences, there are various ways to type Unicode representations, but they all seem to be Hexadecimal:

  • \uFFFF - From C# / Java Strings
  • \U0000FFFF - From C# / Java Strings

However, Unicode can also be specified in decimal, and can be entered both ways in XML Entities:

  • Hexadecimal: 
  • Decimal: 

While I could just (kind of) use \u65535, this does make something that is already defined as specifically hexadecimal and abuse it, and also could cause problems - is \u1111 decimal or hex?

So - are there any programming languages that allow similar ways to denote Unicode characaters by decimal, or common shorthand conventions for specifying Unicode in decimal notation for technical audiences?

  • 1
    please don't cross-post: stackoverflow.com/questions/29044742/… – gnat Mar 14 '15 at 6:22
  • What are my options? It's getting closed on SO, I don't see any option to move it to this site, and read the FAQ and thought it belonged here. Am I able to move my questions across sites, and missed it? – Ehryk Mar 14 '15 at 7:14
  • 1
    Unicode is designed to place different character sets in particular hexadecimal ranges. Referring to them with decimal values, while possible, is not the way to go. It's much easier to remember that Hiragana starts at 0x3040 than 12352. – Steven Burnap Mar 14 '15 at 18:00
  • Certain uses, like XML Entities and Windows Alt{Numpad Entry} use decimal, and what is 'easy to remember' is subjective. Sometimes there are reasons to specify the decimal value, and I'm wondering if anything already supports the equivalent of \u for decimals (yes/no), and if not what a good way to type it when/if a situation arises. – Ehryk Mar 14 '15 at 19:09
  • 2
    I think you need to show a good specific case where you'd have a reason to use the decimal form. It's certainly not common form, and I simply don't see a reason for it. – raptortech97 Mar 14 '15 at 20:18
4

There is no commonly accepted decimal notation for Unicode codepoints.

Unicode codepoints are almost universally represented in hexadecimal. The sole exception I'm aware of is the use of Numeric Character References (NCRs) in languages derived from SGML (e.g., HTML and XML), which can take one of two forms: &#nnn; in decimal or &#xnnn; in hexadecimal.

In other contexts, some languages have attempted to intermingle differing numeric bases - the best-known example being C's use of nnn for decimal, 0nnn for octal, and 0xnnn for hexadecimal. Even with this well-known usage, it trips up beginning C programmers all the time that 012 and 12 are different numbers.

  • Thank you. I looked into the more common languages (C#, C, C++, Java) and couldn't find decimal based notation. If indeed there is no language support, is there any notation that would communicate this to you (personally) aside from &#nnn; or writing out the unicode code-point for decimal 123? – Ehryk Mar 16 '15 at 4:30
  • Why bother? Instead, fully embrace this rare, near-universal, agreement on notation. – Ross Patterson Mar 16 '15 at 9:28
  • @Ehryk: You can write wchar_t(123) when you mean U+007B. But that's a single character, not part of a string. – MSalters Mar 16 '15 at 16:38
  • I value completeness of features more than agreement on a subset of them, which is why I'm bothering. @MSalters, I suppose NCHAR(123) would convey that as well, from MS SQL Server, thanks. – Ehryk Mar 16 '15 at 16:59
  • Well, how many bases would you need for feature completeness? There's one canonical base, and that's hex. – MSalters Mar 16 '15 at 20:48
0

So far here are some ways decimal Unicode can be specified enough to convey the meaning to anyone who searches:

  • XML Entity Notation: &#nnn;
  • C / C++ Wide Character: wchar_t(nnn)
  • SQL National Character: NCHAR(nnn) (Available in MSSQL, MySQL, Oracle)
  • Windows ALT Notation: ALT+nnn (although it can be easily confused with the hex version with the plus key, ALT++01bd)

I'm interested in any others to add to this list.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.