On Sunday, 21 September 2014 at 03:00:34 UTC, Charles McAnany
wrote:
Friends,
I note that there are playing cards in unicode:
http://en.wikipedia.org/wiki/Playing_cards_in_Unicode
They follow a nice pattern, so I can quickly convert from a
rank and suit to the appropriate escape sequence in D. I'd like
to automate this, but I can't seem to do arithmetic on unicode
characters as I could in ascii.
writefln("%c", '/U0001F0A1'); //works fine, ace of spades.
Backslash replaced with / for displayability.
//So logically, this would be the two of spades:
writefln("%c", '/U0001F0A1'+1); //
std.format.FormatException@format.d(1325): integral
Would this be solvable with a mixin (return "//U00001F0A" ~
rank;), or are escape sequences impossible to generate after
the source has been lexed by dmd?
I looked in std.uni and std.utf, but they don't seem to want to
generate a unicode character from an int, they're more
concerned about switching between encodings.
Cheers,
Charles.
see more example
http://techgurulab.com/course/java-quiz-online/