473,563 Members | 2,668 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3536
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.co m

"Gidi" <sh*****@hotmai l.com.dontspam> wrote in message
news:14******** *************** ***********@mic rosoft.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
10676
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 in unicode (I am unsure of which flavour or bit depth). as I read in the file one line at a time (readlines()) it converts to ascii. Simple enough....
11
3202
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 = 0x00; UCHAR outBuffer;
30
8623
by: John Carroll | last post by:
Does anyone have a function or procedure for converting integers to character strings? Thank you, John
13
12669
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 mapped to a char* in my managed-c++-function. Here is the prototype: ---------------------- managed c++ class library project...
10
8029
by: Nikolay Petrov | last post by:
How can I convert DOS cyrillic text to Unicode
6
3233
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 the web service method the values have only the LF chars. What's happening here?
5
7776
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 of bytes. For example, the .lib contains this function: int create(int id, int scale, unsigned char *image); In the wrapper DLL I have this...
8
8479
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. Response.ContentEncoding=System.Text.Encoding.Unicode; Response.ContentType = "application/postscript"; Response.Buffer =true;...
1
2747
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 used. If this file is given to someone with some other current codepage, the file is not displayed correctly. Simply converting the file to Unicode...
0
7664
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7583
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7885
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7638
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6250
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3642
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.