ASCII Character Codes Chart 2

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello, I want to use the above characters codes chart but I dont know how to
set the typeface (documentation: The characters that appear in Windows above
127 depend on the selected typeface).

For example, when I print the chr(205), I am not getting the one shown in
the Chart 2 list...

A step by step approach will be appreciated (in a windows form application).
 
Hello, I want to use the above characters codes chart but I dont know how to
set the typeface (documentation: The characters that appear in Windows above
127 depend on the selected typeface).

The silence is deafening on this question. I've been watching it all day
hoping for an answer, and it appears that none is forthcoming.

I think what is at issue is the code page, and I don't see anything in .net
about code pages. Also, it may not be code pages at all - I don't know.

I hope some kind and knowledgable soul answers this question.
 
Marcel Saucier said:
Hello, I want to use the above characters codes chart but I dont
know how to set the typeface (documentation: The characters that
appear in Windows above 127 depend on the selected typeface).

For example, when I print the chr(205), I am not getting the one
shown in the Chart 2 list...

A step by step approach will be appreciated (in a windows form
application).


You convert a character code (like 205) to a char by using the GetString
function of the System.Text.Encoding class. As Strings are stored as
Unicode, the character code must be converted from the source code page to
Unicode. There are some predefined Encoding objects, like
System.Text.Encoding.Default or System.Text.Encoding.ASCII (7 bit only!). If
you need a different encoding, create it by a call to
System.Text.Encoding.GetEncoding. Example:

Imports System.Text
'...

Dim en As Encoding
Dim b(0) As Byte
Dim s As String

en = Encoding.GetEncoding(850) 'Westeuropean (DOS)
b(0) = 205
s = en.GetString(b)


I guess you're referring to this one:
http://msdn.microsoft.com/library/d...l/_pluslang_ascii_character_codes_chart_2.asp

That's probably code page 437 ("OEM USA").


Armin
 
Your technique works but, with code page 437, character 205 still do no
correspond to the ASCII Character Codes Chart 2...

What is the code page number of that Chart ?
 
Or knowing the corresponding value of CHR(205) of chart 2 using the CHRW
function would be so simple ! But how to find out ?
 
Marcel Saucier said:
Your technique works but, with code page 437, character 205 still do
no correspond to the ASCII Character Codes Chart 2...


Here it works. If I use code 205 and code page 437, I get the "=" as shown
in the chart.

What is the code page number of that Chart ?


Which chart?


Armin
 
Uummmm... how about ChrW(205), perhaps?


Marcel Saucier said:
Or knowing the corresponding value of CHR(205) of chart 2 using the CHRW
function would be so simple ! But how to find out ?
 
Interesting, some characters will show properly (like 174), others not (like
those more graphical). Here, character 205 wont show properly.
 
Marcel Saucier said:
Interesting, some characters will show properly (like 174), others
not (like those more graphical). Here, character 205 wont show
properly.


As Stephany asked meanwhile too: Which font do you use? How to you display
the String? And, could you please post the whole code - if you don't use
mine. ;-)

Start "charmap.exe" (maybe has to be installed optionally(?)). Gives a good
insight on which charset Fonts support. Select the font at the top and
enable the extended view.



Armin
 
Marcel said:
Hello, I want to use the above characters codes chart but I dont know how to
set the typeface (documentation: The characters that appear in Windows above
127 depend on the selected typeface).

For example, when I print the chr(205), I am not getting the one shown in
the Chart 2 list...

A step by step approach will be appreciated (in a windows form application).

Ummm... do the smart thing. Use UNICODE. You’ll save yourself a lot of
frustration.

More information:
http://www.joelonsoftware.com/articles/Unicode.html
http://annevankesteren.nl/2004/06/utf-8
http://www.i18nguy.com/UnicodeBenefits.html
http://www.utf-8.com/
http://www.cl.cam.ac.uk/~mgk25/unicode.html

I hope this helps.
...Geshel
--
***********************************************************************
* My reply-to is an automatically monitored spam honeypot. Do not use *
* it unless you want to be blacklisted by SpamCop. Please reply to my *
* first name at my last name dot org. *
***********************************************************************
“Anyone who believes in Intelligent Design (“creationismâ€) is just as
ignorant and ill-educated as someone who believes that the world is
flat, that the Sun circles the Earth or that there really is a tooth
fairy. Darwinism has an overwhelming foundation of evidence that can be
tested and reproduced. Intelligent Design, on the other hand, has no
evidence at all; not one single shred of testable proof. As such,
Intelligent Design is Religious Mythology, and has no right whatsoever
to be in our Science classrooms.†- 99.99+% of Scientists
***********************************************************************
Mignon McLaughlin once said that “A nymphomaniac is a woman [who is] as
obsessed with sex as the average man.†Unfortunately, since true
nymphomaniacs are so rare, this means that it takes an extraordinary
woman to keep up with an ordinary man.
***********************************************************************
 
Try this:

Dim en0 As System.Text.Encoding = System.Text.Encoding.Default
Dim en1 As System.Text.Encoding = System.Text.Encoding.GetEncoding(850)
Dim s As String = ""
For i As Integer = 128 To 255 : s &= Chr(i) : Next ' test pattern
Dim t As String = en1.GetString(en0.GetBytes(s)) ' t is s converted to
cp 850
s = s & vbLf & t ' output this to a monospace textbox or richtextbox

The trick is to use code page 850 which displays like the code chart.
 
Marcel,

Marcel Saucier said:
Hello, I want to use the above characters codes chart but I dont know how
to
set the typeface (documentation: The characters that appear in Windows
above
127 depend on the selected typeface).

For example, when I print the chr(205), I am not getting the one shown in
the Chart 2 list...

A step by step approach will be appreciated (in a windows form
application).

What's the "Chart 2" list? .NET Windows Forms should be Unicode-aware.
Maybe the font you are using does not contain glyphs for the characters you
want to display. Additional information about character codes can be found
here:

<URL:http://www.microsoft.com/globaldev/reference/cphome.mspx>
 
A big Thank You to all of you... Using charmap.exe & unicode only works well.
My problem was that I was mixing fonts: using an arial font into a Microsoft
Sans Serif font Rich Text Box. Now my RTB is arial with this simple (for
me...) coding:

Public Shared S As String

S = ChrW(9552) 'ARIAL CONTINUOUS DOUBLE LINE... USE CHARMAP.EXE & CONVERT
HEX (U+2550) TO DEC (9552)
....
If Mid(TAB_DATA(I), 25, 4) <> Space(4) Then RTB1.Text = RTB1.Text &
StrDup(21, S) & Chr(13)

Also, thanks for the tip on code page 850.
 
AMercer said:
Try this:

Dim en0 As System.Text.Encoding = System.Text.Encoding.Default
Dim en1 As System.Text.Encoding = System.Text.Encoding.GetEncoding(850)
Dim s As String = ""
For i As Integer = 128 To 255 : s &= Chr(i) : Next ' test pattern
Dim t As String = en1.GetString(en0.GetBytes(s)) ' t is s
converted to cp 850
s = s & vbLf & t ' output this to a monospace textbox or
richtextbox

The trick is to use code page 850 which displays like the code
chart.


That's a different bet. :-) I showed you how to convert a character code to
a string applying a certain code page. You are using the chr function. It
uses the current ANSI codepage (here 1252 "Westeuropean (Windows)"). On
that page, character #205 looks different to that on the chart you are
referring to.

What your code does is:
Create as string containing characters 128 to 255 from the current ANSI
codepage - not from codepage 437 like on the chart. Then you convert back to
exactly the same array because you are again using
System.Text.Encoding.Default. After that, you use code page 850 to convert
that array to a string again. This doesn't make sense because a) superfluous
string <-> byte array converions b) different assumptions of the code page
used for the character codes in the array (ansi vs. cp 850).

In the end, the code does the same as the one I gave already before. The
only difference is that I showed only one character instead of 128-255. You
can make your code much less complicated:

Dim b(127) As Byte
Dim en As Encoding = Encoding.GetEncoding(850)
Dim s As String

For i As Integer = 128 To 255
b(i - 128) = CByte(i)
Next

s = en.GetString(b)


Armin
 
That's a different bet. :-) I showed you how to convert a character code to
a string applying a certain code page. You are using the chr function. It
uses the current ANSI codepage (here 1252 "Westeuropean (Windows)"). On
that page, character #205 looks different to that on the chart you are
referring to.

The idea was to map bytes 128..255 to their cp850 values just to see the
display.
Create as string containing characters 128 to 255 from the current ANSI
codepage - not from codepage 437 like on the chart.

Right - bytes 128..255.
Then you convert back to
exactly the same array because you are again using
System.Text.Encoding.Default.

Just a gimmick to go from string to byte() because Encoding.GetString
requires a byte array. Maybe you could suggest a better way to convert a
string to a byte array.
After that, you use code page 850 to convert
that array to a string again. This doesn't make sense because a) superfluous
string <-> byte array converions

just a gimmick to convert the string from default bytes because bytes are
required to go to 850 via GetString.
b) different assumptions of the code page
used for the character codes in the array (ansi vs. cp 850).

I don't understand this. All I wanted to do was show a string with 128..255
under default cp and then map it to 850 and see the difference.
In the end, the code does the same as the one I gave already before. The
only difference is that I showed only one character instead of 128-255. You
can make your code much less complicated:

Dim b(127) As Byte
Dim en As Encoding = Encoding.GetEncoding(850)
Dim s As String

For i As Integer = 128 To 255
b(i - 128) = CByte(i)
Next

I understand, but usually my givens are strings, not byte arrays. This is
really much ado about nothing. All I was trying to do in the first place was
show what 128..255 look like in two code pages on the same display.
 
AMercer said:
The idea was to map bytes 128..255 to their cp850 values just to see
the display.


Right - bytes 128..255.


Just a gimmick to go from string to byte() because
Encoding.GetString requires a byte array. Maybe you could suggest a
better way to convert a string to a byte array.

I didn't say that encoding.getstring is not the way to go. I said that in
order to show the characters 128-255 on cp 850 it is not necessary to do so
many conversions that you did: 1. convert from ansi cp to unicode by using
chr, 2. encoding.getbytes to get back the same values you just passed to
chr, 3. encoding.getstring to convert again to get the cp 850 display.
just a gimmick to convert the string from default bytes because
bytes are required to go to 850 via GetString.

I see, but I think it can be done less complicated.
I don't understand this. All I wanted to do was show a string with
128..255 under default cp and then map it to 850 and see the
difference.

No problem, but the way you did it is..see above.
I understand, but usually my givens are strings, not byte arrays.
This is really much ado about nothing. All I was trying to do in
the first place was show what 128..255 look like in two code pages
on the same display.

I only wanted to say that the way you did it is pretty complicated and
confusing. What was also not clear to me: By using GetBytes you get an array
containing the default encoding. After that you interpret the same array as
being CP 850 encoded characters.


Armin
 
Herfried,

I should have looked first at your answer. (Armins answer is of course as
well correct)

As you probably know did I hate forever that 850 one "International Latin",
from which every hardware seller was setting the computers in Holland, while
the 437 was more proper for Holland, because it has a florin character. (And
than 50% in Holland became 437 and the other half 850). Now we have luckily
almost all in Germanic/Roman derived languages the 1252.

Nice link by the way, I have replaced that one you probably have seen from
Athene by this one, although I keep this one

http://www.microsoft.com/globaldev/reference/oslocversion.mspx

:-)

Cor
 
Back
Top