473,385 Members | 1,351 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,385 software developers and data experts.

ASCII charcters from 0x21 to 0xff

Hi all.

What I want to do is create a control array using labels (I already figure
out how to create a control array) with 1 label equal to the ASCII font
character it displays. What I have found out is every font character from
0x79 to 0xA0 that get converted to a string contains the 4 sided block
character. I want to be all separate characters. Using the following:
Encoding u16LE = Encoding.Unicode;

char[] DisplayCount = new char[0xff-0x20];

for (int i = 0; i < 0xff - 0x20; i++)

{

DisplayCount[i] = Convert.ToChar(i + 0x21);

}

bytes = u16LE.GetBytes(DisplayCount);

I have tried:
aLabel.Text = Convert.ToString(Convert.ToChar(bytes[2 * (this.Count - 1)]));

aLabel.Text = String.Format("{0}",
Convert.ToChar((bytes[2*(this.Count-1)])));

aLabel.Text = (Convert.ToChar((bytes[2*(this.Count-1)])).ToString();

aLabel.Text = Convert.ToChar(this.Count + 0x20).ToString();

So, I think is it is related is the string. Could somebody offer a
suggestion?

Scott
Jan 10 '06 #1
17 8247
"Scott Starker" <Sc***********@sil.org> wrote in message
news:eU****************@TK2MSFTNGP10.phx.gbl...
So, I think is it is related is the string. Could somebody offer a
suggestion?


The font you are using does not have these character. You need to find a
font that does.

Michael
Jan 10 '06 #2
No. I don't believe so. All the fonts are this way include the ANSI fonts.

"Michael C" <mc*****@NOSPAMoptushome.com.au> wrote in message
news:OG**************@TK2MSFTNGP09.phx.gbl...
"Scott Starker" <Sc***********@sil.org> wrote in message
news:eU****************@TK2MSFTNGP10.phx.gbl...
So, I think is it is related is the string. Could somebody offer a
suggestion?


The font you are using does not have these character. You need to find a
font that does.

Michael

Jan 10 '06 #3
"Scott Starker" <Sc***********@sil.org> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
No. I don't believe so. All the fonts are this way include the ANSI fonts.


Some fonts at least will have some of these chrs.

Michael
Jan 10 '06 #4
"Scott Starker" <Sc***********@sil.org> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
No. I don't believe so. All the fonts are this way include the ANSI fonts.


BTW, I think your code should look something like this:

string s = string.empty;
for i = whatever to whatever
{
s+= Convert.ToChar(i)
}
label1.text = s;

Michael
Jan 10 '06 #5
Hi,

Scott Starker wrote:
I have found out is every font character from 0x79 to 0xA0 that get
converted to a string contains the 4 sided block character. I want to be
all separate characters.
Using the following: Encoding u16LE = Encoding.Unicode;


What you have found is true. Unicode characters in that range are defined
as control characters (similar to characters under 0x20) and have no visual
representation. You may wish to consult:

http://www.google.com/search?hl=en&q...+character+map

If you were expecting something else, you were expecting results from
different encoding, such as ISO-8859-1 -- but probably not ASCII as
mentioned in the subject of your post, for that would be undefined above
0x7F entirely.
--
Chris Priede
Jan 10 '06 #6
Scott Starker <Sc***********@sil.org> wrote:
What I want to do is create a control array using labels (I already figure
out how to create a control array) with 1 label equal to the ASCII font
character it displays. What I have found out is every font character from
0x79 to 0xA0 that get converted to a string contains the 4 sided block
character.


You need to understand that those characters *aren't* in ASCII. I
suspect you want the characters in the default encoding instead
(Encoding.Default). Try converting byte 0x79 into a character using the
default encoding, and you may well find it gives what you expect. Just
don't think that that's ASCII, or that it'll give the same result on
all computers.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 10 '06 #7
Having to delve into this, I know that ASCII is seven-bit code (0x0 -
0x7f).

In addition to the ASCII characters, ISO Latin 1 (ISO 8859-1) contains
various accented characters and other letters needed for writing
languages of Western Europe, and some special characters. These
characters occupy code positions 0xa0 - 0xff.

But there are 21 characters in the middle that are not displayed. In the
Windows character set (Windows code page 1252), some positions in the
range 0x80 - 0x9f are assigned to printable characters, such as "smart
quotes", em dash, en dash, and trademark symbol. I need to know how to
get these characters assigned to the labels. I wrote a program in VB6
which does this.

Hmmm... what about changing the code page... I'll give it a try...

*** Sent via Developersdex http://www.developersdex.com ***
Jan 10 '06 #8
Scott Starker <sc***********@sil.org> wrote:
Having to delve into this, I know that ASCII is seven-bit code (0x0 -
0x7f).

In addition to the ASCII characters, ISO Latin 1 (ISO 8859-1) contains
various accented characters and other letters needed for writing
languages of Western Europe, and some special characters. These
characters occupy code positions 0xa0 - 0xff.

But there are 21 characters in the middle that are not displayed. In the
Windows character set (Windows code page 1252), some positions in the
range 0x80 - 0x9f are assigned to printable characters, such as "smart
quotes", em dash, en dash, and trademark symbol. I need to know how to
get these characters assigned to the labels. I wrote a program in VB6
which does this.

Hmmm... what about changing the code page... I'll give it a try...


Changing the code page changes potentially a *lot* of the character
set. It's not that "the Windows character set" is Windows CP 1252 -
that's just the default for the US and Western Europe, I believe. Try
installing in Eastern Europe and I suspect you'd get a different
default...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 10 '06 #9
In running the program, under Encoding.Default I get:
BodyName: "iso-8859-1"
CodePage: 1252
HeaderName: "Windows-1252"
WebName: "Windows-1252"
WindowsCodePage: 1252
How do you make "Windows-1252" or 1252 win over "iso-8859-1"? They're not
the same.

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Scott Starker <sc***********@sil.org> wrote:
Having to delve into this, I know that ASCII is seven-bit code (0x0 -
0x7f).

In addition to the ASCII characters, ISO Latin 1 (ISO 8859-1) contains
various accented characters and other letters needed for writing
languages of Western Europe, and some special characters. These
characters occupy code positions 0xa0 - 0xff.

But there are 21 characters in the middle that are not displayed. In the
Windows character set (Windows code page 1252), some positions in the
range 0x80 - 0x9f are assigned to printable characters, such as "smart
quotes", em dash, en dash, and trademark symbol. I need to know how to
get these characters assigned to the labels. I wrote a program in VB6
which does this.

Hmmm... what about changing the code page... I'll give it a try...


Changing the code page changes potentially a *lot* of the character
set. It's not that "the Windows character set" is Windows CP 1252 -
that's just the default for the US and Western Europe, I believe. Try
installing in Eastern Europe and I suspect you'd get a different
default...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Jan 11 '06 #10
Scott Starker <Sc***********@sil.org> wrote:
In running the program, under Encoding.Default I get:
BodyName: "iso-8859-1"
CodePage: 1252
HeaderName: "Windows-1252"
WebName: "Windows-1252"
WindowsCodePage: 1252
How do you make "Windows-1252" or 1252 win over "iso-8859-1"? They're not
the same.


Running which program? Anyway, I suspect the reason it uses iso-8859-1
as the BodyName is that it's the closest MIME-compatible encoding to
Windows 1252.

However, if you want to use ISO-8859-1 at any point, just use
Encoding.GetEncoding(28591).

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 11 '06 #11
> Running which program?

With Microsoft Visual C# 2005 running in "Start Debbuging" with my C# code
:) I had the debbuger go down to this.AddNewLabel(font)
Encoding Default = Encoding.Default;
char[] DisplayCount = new char[0xff-0x20];
for (int i = 0; i < 0xff - 0x20; i++)
{
DisplayCount[i] = Convert.ToChar(i + 0x21);
}
bytes = Default.GetBytes(DisplayCount);
this.AddNewLabel(fonts);
And in "Locals" I click on "Default" to show this list. (I know that you
knew that :) )

What I WANT is Windows-1252 and not "iso-8859-1". If C# wont allow
Windows-1252 to be used I'll have to stick when VB6 for this program.

Scott

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Scott Starker <Sc***********@sil.org> wrote:
In running the program, under Encoding.Default I get:
BodyName: "iso-8859-1"
CodePage: 1252
HeaderName: "Windows-1252"
WebName: "Windows-1252"
WindowsCodePage: 1252
How do you make "Windows-1252" or 1252 win over "iso-8859-1"? They're not
the same.


Running which program? Anyway, I suspect the reason it uses iso-8859-1
as the BodyName is that it's the closest MIME-compatible encoding to
Windows 1252.

However, if you want to use ISO-8859-1 at any point, just use
Encoding.GetEncoding(28591).

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Jan 11 '06 #12
Scott Starker wrote:
What I WANT is Windows-1252 and not "iso-8859-1". If C# wont allow
Windows-1252 to be used I'll have to stick when VB6 for this program.


You can use 1252 whenever you like - just use
Encoding.GetEncoding(1252) and then use that to convert between text
and binary.

Jon

Jan 11 '06 #13
It is not the string but the char. In order to put character into Label I
have to use char to go to string. But "the.NET Framework uses the Char
structure to represent Unicode characters". Ugh! And there is no way that I
can get 0x80 - 0xa0 characters to display on the labels with unicode! Well,
back to VB6...

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Scott Starker wrote:
What I WANT is Windows-1252 and not "iso-8859-1". If C# wont allow
Windows-1252 to be used I'll have to stick when VB6 for this program.


You can use 1252 whenever you like - just use
Encoding.GetEncoding(1252) and then use that to convert between text
and binary.

Jon

Jan 11 '06 #14
Scott Starker <Sc***********@sil.org> wrote:
It is not the string but the char. In order to put character into Label I
have to use char to go to string. But "the.NET Framework uses the Char
structure to represent Unicode characters". Ugh! And there is no way that I
can get 0x80 - 0xa0 characters to display on the labels with unicode! Well,
back to VB6...


The 0x80 - 0xa0 you're talking about aren't characters though - they're
bytes which are the result of encoding characters. So to get characters
from those bytes, just use Encoding.GetString (bytes). As you want a
single byte to single character map, you might as well use:

byte[] bytes = new byte[256];
for (int i=0; i < bytes.Length; i++)
{
bytes[i] = (byte)i;
}
char[] chars=Encoding.GetEncoding(1252).GetString(bytes). ToCharArray();

The problem was that you were converting from byte to char without
taking any specific encoding into account - or rather, assuming UTF-16,
effectively.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 11 '06 #15
Jon,

AWESOME! You did it! I didn't think about using GetString(bytes)...

However, you only have half of it. The problem is that there aren't any
characters for 0x80 - 0xa0 in Unicode. And char always gives Unicode
"characters". But since GetString(bytes) (under Encoding.GetEncoding(1252))
gives Unicode fonts for fonts 0x80 - 0xa0 I (eg. 0x80 = 8362 Unicode "?")
still don't have a single byte to single character map (eg. 0x80 = 0x80
"?"). Your solution works but only half way.

I'm trying to write a program that lists a ButtonArray of custom-made-font
(256 characters) and a LabelArray Arial font (256 characters) and have the
user click on the custom-make-font that changed because they don't go with
the Arial font. Your solution works for the Arial but not with the
custom-made-fonts. So, any ideas as to how to do 0x80 - 0xa0 (eg. 0x80 =
0x80 "?")?

Scott

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Scott Starker <Sc***********@sil.org> wrote:
It is not the string but the char. In order to put character into Label I
have to use char to go to string. But "the.NET Framework uses the Char
structure to represent Unicode characters". Ugh! And there is no way that
I
can get 0x80 - 0xa0 characters to display on the labels with unicode!
Well,
back to VB6...


The 0x80 - 0xa0 you're talking about aren't characters though - they're
bytes which are the result of encoding characters. So to get characters
from those bytes, just use Encoding.GetString (bytes). As you want a
single byte to single character map, you might as well use:

byte[] bytes = new byte[256];
for (int i=0; i < bytes.Length; i++)
{
bytes[i] = (byte)i;
}
char[] chars=Encoding.GetEncoding(1252).GetString(bytes). ToCharArray();

The problem was that you were converting from byte to char without
taking any specific encoding into account - or rather, assuming UTF-16,
effectively.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Jan 12 '06 #16
Scott Starker <Sc***********@sil.org> wrote:
AWESOME! You did it! I didn't think about using GetString(bytes)...

However, you only have half of it. The problem is that there aren't any
characters for 0x80 - 0xa0 in Unicode.
Well, those characters do exist, but they're non-printable.
And char always gives Unicode
"characters". But since GetString(bytes) (under Encoding.GetEncoding(1252))
gives Unicode fonts for fonts 0x80 - 0xa0 I (eg. 0x80 = 8362 Unicode "?")
still don't have a single byte to single character map (eg. 0x80 = 0x80
"?"). Your solution works but only half way.
The unicode character is independent of the font, but you need to use a
font which can display the unicode character appropriately.
I'm trying to write a program that lists a ButtonArray of custom-made-font
(256 characters) and a LabelArray Arial font (256 characters) and have the
user click on the custom-make-font that changed because they don't go with
the Arial font. Your solution works for the Arial but not with the
custom-made-fonts. So, any ideas as to how to do 0x80 - 0xa0 (eg. 0x80 =
0x80 "?")?


If the font is displaying Unicode 0x80 as if it were Unicode 8362, then
you just need to use the implicit conversion from byte to char (or
explicitly convert from int to char with a cast expression). I'd say
the font is broken, however.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 12 '06 #17
Jon,

Forget my message before this one! When the Unicode font is "made" from the
custom-made-font (it has only 256 characters) the 0x80 - 0xa0 are exactly
they are in 0x80 - 0xa0. Thus, for instance, 0x80 is "supposed" to be 8362
Unicode (that's what the "chars" says) but it displays 0x80! I didn't even
let the characters be display because the "chars" says that it was wrong but
one time I did. It must be because the font has 256 characters. Very
interesting...

Thanks again!

Scott

"Scott Starker" <Sc***********@sil.org> wrote in message
news:O1*************@TK2MSFTNGP14.phx.gbl...
Jon,

AWESOME! You did it! I didn't think about using GetString(bytes)...

However, you only have half of it. The problem is that there aren't any
characters for 0x80 - 0xa0 in Unicode. And char always gives Unicode
"characters". But since GetString(bytes) (under
Encoding.GetEncoding(1252)) gives Unicode fonts for fonts 0x80 - 0xa0 I
(eg. 0x80 = 8362 Unicode "?") still don't have a single byte to single
character map (eg. 0x80 = 0x80 "?"). Your solution works but only half
way.

I'm trying to write a program that lists a ButtonArray of custom-made-font
(256 characters) and a LabelArray Arial font (256 characters) and have the
user click on the custom-make-font that changed because they don't go with
the Arial font. Your solution works for the Arial but not with the
custom-made-fonts. So, any ideas as to how to do 0x80 - 0xa0 (eg. 0x80 =
0x80 "?")?

Scott

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Scott Starker <Sc***********@sil.org> wrote:
It is not the string but the char. In order to put character into Label
I
have to use char to go to string. But "the.NET Framework uses the Char
structure to represent Unicode characters". Ugh! And there is no way
that I
can get 0x80 - 0xa0 characters to display on the labels with unicode!
Well,
back to VB6...


The 0x80 - 0xa0 you're talking about aren't characters though - they're
bytes which are the result of encoding characters. So to get characters
from those bytes, just use Encoding.GetString (bytes). As you want a
single byte to single character map, you might as well use:

byte[] bytes = new byte[256];
for (int i=0; i < bytes.Length; i++)
{
bytes[i] = (byte)i;
}
char[] chars=Encoding.GetEncoding(1252).GetString(bytes). ToCharArray();

The problem was that you were converting from byte to char without
taking any specific encoding into account - or rather, assuming UTF-16,
effectively.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too


Jan 13 '06 #18

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...
5
by: Sam Smith | last post by:
Hi, is there a function or a "well-known" algorithm which converts a number of random length represented as an array of bytes to its binary format? For example: a 16 byte long array:...
5
by: mail2atulmehta | last post by:
I have a question. how to generate two files, one in UTF-8, the other in ASCII with the same column length SO that when i do the conversion from utf-8 to ascii, the column length does not change ....
12
by: chunhui_true | last post by:
i have a class, it can read one line(\r\n ended) from string,when i read line from utf8 string i can't get any thing! maybe i should conversion utf8 to ascii??there is any function can conversion...
1
by: Scott Duckworth | last post by:
Can anyone provide a quick code snippit to open a text file and tell if it's ASCII or Unicode? Thanks
5
by: fidtz | last post by:
The code: import codecs udlASCII = file("c:\\temp\\CSVDB.udl",'r') udlUNI = codecs.open("c:\\temp\\CSVDB2.udl",'w',"utf_16") udlUNI.write(udlASCII.read()) udlUNI.close()
6
by: ssetz | last post by:
Hello, For work, I need to write a password filter. The problem is that my C+ + experience is only some practice in school, 10 years ago. I now develop in C# which is completely different to me....
23
by: Jorge Peixoto | last post by:
In the answer to question 12.42 of the C FAQ, we have this code: putc((unsigned)((s.i32 >24) & 0xff), fp); putc((unsigned)((s.i32 >16) & 0xff), fp); putc((unsigned)((s.i32 >8) & 0xff), fp);...
44
by: Pilcrow | last post by:
Is there a way that a proram can detect whether it is operating in an ASCII or an EBCDIC environment?
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.