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).
--
Super Basic programmer under DOS since 1983. Absolutely dummy VB.NET
programmer under Windows ! 18 8703
> 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" <Ma***********@discussions.microsoft.com> schrieb 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/de...es_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 ?
--
Super Basic programmer under DOS since 1983. Absolutely dummy VB.NET
programmer under Windows !
"Armin Zingler" wrote: "Marcel Saucier" <Ma***********@discussions.microsoft.com> schrieb 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/de...es_chart_2.asp
That's probably code page 437 ("OEM USA").
Armin
Or knowing the corresponding value of CHR(205) of chart 2 using the CHRW
function would be so simple ! But how to find out ?
--
Super Basic programmer under DOS since 1983. Absolutely dummy VB.NET
programmer under Windows !
"Armin Zingler" wrote: "Marcel Saucier" <Ma***********@discussions.microsoft.com> schrieb 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/de...es_chart_2.asp
That's probably code page 437 ("OEM USA").
Armin
"Marcel Saucier" <Ma***********@discussions.microsoft.com> schrieb 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" <Ma***********@discussions.microsoft.com> wrote in message
news:72**********************************@microsof t.com... Or knowing the corresponding value of CHR(205) of chart 2 using the CHRW function would be so simple ! But how to find out ? -- Super Basic programmer under DOS since 1983. Absolutely dummy VB.NET programmer under Windows !
"Armin Zingler" wrote:
"Marcel Saucier" <Ma***********@discussions.microsoft.com> schrieb > 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/de...es_chart_2.asp
That's probably code page 437 ("OEM USA").
Armin
Interesting, some characters will show properly (like 174), others not (like
those more graphical). Here, character 205 wont show properly.
--
Super Basic programmer under DOS since 1983. Absolutely dummy VB.NET
programmer under Windows !
"Armin Zingler" wrote: "Marcel Saucier" <Ma***********@discussions.microsoft.com> schrieb 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
I already have tried it... not working...
--
Super Basic programmer under DOS since 1983. Absolutely dummy VB.NET
programmer under Windows !
"Stephany Young" wrote: Uummmm... how about ChrW(205), perhaps?
"Marcel Saucier" <Ma***********@discussions.microsoft.com> wrote in message news:72**********************************@microsof t.com... Or knowing the corresponding value of CHR(205) of chart 2 using the CHRW function would be so simple ! But how to find out ? -- Super Basic programmer under DOS since 1983. Absolutely dummy VB.NET programmer under Windows !
"Armin Zingler" wrote:
"Marcel Saucier" <Ma***********@discussions.microsoft.com> schrieb > 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/de...es_chart_2.asp
That's probably code page 437 ("OEM USA").
Armin
What do you actually get?
What typeface (font) are you using?
"Marcel Saucier" <Ma***********@discussions.microsoft.com> wrote in message
news:25**********************************@microsof t.com... I already have tried it... not working... -- Super Basic programmer under DOS since 1983. Absolutely dummy VB.NET programmer under Windows !
"Stephany Young" wrote:
Uummmm... how about ChrW(205), perhaps?
"Marcel Saucier" <Ma***********@discussions.microsoft.com> wrote in message news:72**********************************@microsof t.com... > Or knowing the corresponding value of CHR(205) of chart 2 using the > CHRW > function would be so simple ! But how to find out ? > -- > Super Basic programmer under DOS since 1983. Absolutely dummy VB.NET > programmer under Windows ! > > > "Armin Zingler" wrote: > >> "Marcel Saucier" <Ma***********@discussions.microsoft.com> schrieb >> > 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/de...es_chart_2.asp >> >> That's probably code page 437 ("OEM USA"). >> >> >> Armin >> >>
"Marcel Saucier" <Ma***********@discussions.microsoft.com> schrieb 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 Saucier wrote: 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" <Ma***********@discussions.microsoft.com> schrieb: 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>
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
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.
--
Super Basic programmer under DOS since 1983. Absolutely dummy VB.NET
programmer under Windows !
"AMercer" wrote: 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.
"AMercer" <AM*****@discussions.microsoft.com> schrieb 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" <AM*****@discussions.microsoft.com> schrieb 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.
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. 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.
I see, but I think it can be done less complicated. 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.
No problem, but the way you did it is..see above. 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.
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/r...ocversion.mspx
:-)
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Daniel |
last post by:
Hi, is there a way to check if a letter entered is an uppercase ASCII
character?
Thanks
Daniel
|
by: David Williams |
last post by:
Hi all, i have been able to convert an ASCII character to an INT however im
lost as to how to change them back. Cant find anything on the net (though im
probably looking in the wrong places!)....
|
by: Director - Minvent |
last post by:
Hi,
I am reading from a serial port from a device which sends over an ascii
character. It uses the full extended 256 character set and therefore has
non-printing characters too. So what i want...
|
by: chandy |
last post by:
Hi,
I have an Html document that declares that it uses the utf-8 character
set. As this document is editable via a web interface I need to make
sure than high-ascii characters that may be...
|
by: akarui.tomodachi |
last post by:
What is the most easiest way to convert an integer value to ASCII
character format ?
I tried with sprintf(). It works.
Is there any other way to do that ?
Objective::
I like to convert an...
|
by: simchajoy2000 |
last post by:
Hi,
I know what the ASCII Character Codes are for the 2nd and 3rd powers in
VB.NET but I can't find the 6th power anywhere - does anyone know what
it might be or if it even exists?
Joy
|
by: davetelling |
last post by:
I am a total newbie, trying to slog through the Visual C# Express
application. I need to be able to convert a single ASCII character (can be
anything from 0 to 255) to an int for use in other...
|
by: =?Utf-8?B?UGhhbmlkaGFy?= |
last post by:
Hi,
I'm developing a Winform application in C#( .net 2.0). I've a dialog box
where user can input text and that text would be sent across to other machine
using sockets.
When the user enters...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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: 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,...
|
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...
|
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...
|
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 projectplanning, coding, testing,...
| |