By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,563 Members | 1,058 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,563 IT Pros & Developers. It's quick & easy.

Char Unicode value and converting to byte

P: n/a
Hi,

I'm writing a C# win application program, and i need to transfer my hebrew
letters from unicode to ascii, now if i use the ascii encoding it writes me
??? instead of the hebrew letter i've entered. I know what the Ascii value of
each letter, so i understood that i can transfer my string to BYTE and enter
the ascii value by myself. if someone has a better idea, i'll be happy to
hear about it.
how can i know the Unicode value of a charter while the program running? i
want to make subtraction between the unicode value to the difference in Ascii
so i'll always get the ASCII value.

one more thing, if someone can give me an example how can i convert my char
value to byte.
thanks,
Gidi.
Nov 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Gidi,

This sounds more like translation than encoding. As you have seen,
there isn't an encoding that will translate a Hebrew character into an Ascii
equivalent.

Since you know the character codes of the Hebrew characters you want to
translate, why not do this?

Assume that the Hebrew characters take up unicode characters 600-699
(this is a guess).

What you would do is create an array of 100 elements. If every unicode
mapping maps to a single character, then you can use a char (you should use
a char if you are going to subsequently string together words with these
character) as the array type. If the characters map to multi-character
strings, then the array should be strings.

As you are cycling through your unicode characters, subtract the value
of the low end of the range (in this case, 600). This is the element in the
array to get the equivalent character/string of, and you can append it to
your return string.

You could also place this in a class that derives from Encoding and then
it would help you in a great number of situations.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Gidi" <sh*****@hotmail.com.dontspam> wrote in message
news:14**********************************@microsof t.com...
Hi,

I'm writing a C# win application program, and i need to transfer my hebrew
letters from unicode to ascii, now if i use the ascii encoding it writes
me
??? instead of the hebrew letter i've entered. I know what the Ascii value
of
each letter, so i understood that i can transfer my string to BYTE and
enter
the ascii value by myself. if someone has a better idea, i'll be happy to
hear about it.
how can i know the Unicode value of a charter while the program running? i
want to make subtraction between the unicode value to the difference in
Ascii
so i'll always get the ASCII value.

one more thing, if someone can give me an example how can i convert my
char
value to byte.
thanks,
Gidi.

Nov 17 '05 #2

P: n/a
Gidi wrote:
I'm writing a C# win application program, and i need to transfer my hebrew
letters from unicode to ascii, now if i use the ascii encoding it writes me
??? instead of the hebrew letter i've entered. I know what the Ascii value of
each letter, so i understood that i can transfer my string to BYTE and enter
the ascii value by myself. if someone has a better idea, i'll be happy to
hear about it.


I think you may be under a misapprehension about ASCII. In particular,
it doesn't contain any Hebrew characters.

See http://www.pobox.com/~skeet/csharp/unicode.html

Now, did you actually mean that you know some ASCII translation for
each Hebrew letter?

Jon

Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.