Returning Random Unicode Characters
-
I'm having a bit of a problem getting the Unicode version of this:
((char)((int)'a' + new Random().Next(26))).ToString();
The above snippet returns a random lowercase character. I'm trying to do the same thing for Unicode Characters in the range of 0621 - 064A Suggestions?
If the post was helpful, please vote!
Why won't the worm just leave me be?
-
I'm having a bit of a problem getting the Unicode version of this:
((char)((int)'a' + new Random().Next(26))).ToString();
The above snippet returns a random lowercase character. I'm trying to do the same thing for Unicode Characters in the range of 0621 - 064A Suggestions?
If the post was helpful, please vote!
Why won't the worm just leave me be?
((char)((new Random()).Next(0x621, 0x64A + 1))).ToString();
:~
Too many passwords to remember? Try KeePass Password Safe!
-
((char)((new Random()).Next(0x621, 0x64A + 1))).ToString();
:~
Too many passwords to remember? Try KeePass Password Safe!
Same problem. The problem being char apparently doesn't cover the letters I want to it simply returns a "?" Thanks though
If the post was helpful, please vote!
Why won't the worm just leave me be?
-
Same problem. The problem being char apparently doesn't cover the letters I want to it simply returns a "?" Thanks though
If the post was helpful, please vote!
Why won't the worm just leave me be?
A wild guess: Maybe the Unicode char is in a font you don't have installed.
-
A wild guess: Maybe the Unicode char is in a font you don't have installed.
Nope, Arabic would be a staple of my system being as about 80% of my work is in Arabic (front end) :) The problem is that whenever I try to cast the numeric unicode value of the char seems to "truncate" it which is very strange considering char is a unicode character.
If the post was helpful, please vote!
Why won't the worm just leave me be?
-
Nope, Arabic would be a staple of my system being as about 80% of my work is in Arabic (front end) :) The problem is that whenever I try to cast the numeric unicode value of the char seems to "truncate" it which is very strange considering char is a unicode character.
If the post was helpful, please vote!
Why won't the worm just leave me be?
Maybe changing the encoding might give a different result. UTF-8 uses one byte for the range 0-127, but more bytes for other character sets. UTF-16 uses two bytes for all characters, but is limited to the Basic Multilingual Plane (BMP). The BMP covers most modern languages, including Arabic I'm sure.
-
Maybe changing the encoding might give a different result. UTF-8 uses one byte for the range 0-127, but more bytes for other character sets. UTF-16 uses two bytes for all characters, but is limited to the Basic Multilingual Plane (BMP). The BMP covers most modern languages, including Arabic I'm sure.
Snippet please?
If the post was helpful, please vote!
Why won't the worm just leave me be?
-
Snippet please?
If the post was helpful, please vote!
Why won't the worm just leave me be?
I'm not sure if this will help with your problem, but here's a link to examples that uses encodings with conversions: http://msdn.microsoft.com/en-us/library/system.text.encoding.convert(VS.71).aspx[^] The Encoding class supports multiple Unicode encodings, and I was hypothesizing that the wrong one could have given the symptoms you're seeing.