473,396 Members | 1,608 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Char Unicode value and converting to byte

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
2 3525
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Peter Wilkinson | last post by:
Hello tlistmembers, I am using the encoding function to convert unicode to ascii. At one point this code was working just fine, however, now it has broken. I am reading a text file that has is...
11
by: Chris Online | last post by:
Hi all, I'm using C++ Builder5. I want to get data from an edit-box and send it to a development kit. The dev-kit can only receive char and no char* here's a part of my code: char* Data_byte...
30
by: John Carroll | last post by:
Does anyone have a function or procedure for converting integers to character strings? Thank you, John
13
by: Ekim | last post by:
hy to all, I'm accessing a function from a managed-c++-dll within my c#-application. Therefore I encountered following troubles: In my c#-app I have got a byte-array, which should somehow be...
10
by: Nikolay Petrov | last post by:
How can I convert DOS cyrillic text to Unicode
6
by: NormD | last post by:
I'm sending a string (xml string) to web service as a parameter. One of the tags in the xml string is the address field and the values of this tag have LF + CR chars. When I receive the string in...
5
by: Stephen Cawood | last post by:
I'm trying to use a C++ .lib from C# (I tried the Interop group will no results). I have a working wrapper DLL (I can get back simple things like int), but I'm having issues dealing with an array...
8
by: Andy | last post by:
Hello All: I have a windows application that I need to encode a string using Unicode. The example I have been given to use is a Web-Version. Below is the webcode. ...
1
by: Alexander Higgins | last post by:
>>Thanks for the response.... Point Taken but this is not the case. Thus, if a person writes a text file on her or his computer and does not use UNICODE to save it, the current code page is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.