How to retrun a character with ascii code?
It is useChr(65) return 'A' in VB.NET.
What is the equivalent function in C#? 7 77915
Hi Ad,
char[] characters = System.Text.Encoding.ASCII.GetChars(new byte[] {65});
Yes, looks quite cumbersome and I wonder myself why there is no overload for
a single character (or was I just too lazy to dig MSDN enough? ;-)
--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]
"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:ey**************@tk2msftngp13.phx.gbl... How to retrun a character with ascii code? It is useChr(65) return 'A' in VB.NET. What is the equivalent function in C#?
Hallo!
<Dmytro Lapshyn [MVP]> schrieb... Hi Ad,
char[] characters = System.Text.Encoding.ASCII.GetChars(new byte[] {65});
Yes, looks quite cumbersome and I wonder myself why there is no overload for a single character (or was I just too lazy to dig MSDN enough? ;-)
Why not Convert.ToChar(65) ?
Sincerely
Oskar
Oskar Punz wrote: Hallo!
<Dmytro Lapshyn [MVP]> schrieb...
Hi Ad,
char[] characters = System.Text.Encoding.ASCII.GetChars(new byte[] {65});
Yes, looks quite cumbersome and I wonder myself why there is no overload for a single character (or was I just too lazy to dig MSDN enough? ;-)
Why not Convert.ToChar(65) ?
char c = (char) 65;
works as well, though I consider it less readable.
Cheers,
-- http://www.joergjooss.de
mailto:ne********@joergjooss.de
Hallo Oskar,
I think Convert.ToChar as well as (char)65 assume the Unicode encoding,
while the author has explicitly mentioned the ASCII one.
Yes, the character codes of the capital 'A' are the same in both of the
encodings, but this, in general, might be not true for other character codes
and other encodings.
--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]
"Oskar Punz" <da***************@utanet.at> wrote in message
news:u7**************@TK2MSFTNGP14.phx.gbl... Hallo!
<Dmytro Lapshyn [MVP]> schrieb...
Hi Ad,
char[] characters = System.Text.Encoding.ASCII.GetChars(new byte[] {65});
Yes, looks quite cumbersome and I wonder myself why there is no overload for a single character (or was I just too lazy to dig MSDN enough? ;-)
Why not Convert.ToChar(65) ?
Sincerely
Oskar
Hi!
<Dmytro Lapshyn [MVP]> schrieb... Hallo Oskar,
I think Convert.ToChar as well as (char)65 assume the Unicode encoding, while the author has explicitly mentioned the ASCII one. Yes, the character codes of the capital 'A' are the same in both of the encodings, but this, in general, might be not true for other character codes and other encodings.
AFAIK the first 128 Unicode characters are the same as the
ASCII characters (except an extra leading zero byte).
So as long as you don't use values above 127 nothing
can go wrong. Right?
Ciao
Oskar
For every character which has an ASCII code, it's the same in UNICODE
(expanded to 16-bits)
--
--
Truth,
James Curran
[erstwhile VC++ MVP]
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
"Dmytro Lapshyn [MVP]" <x-****@no-spam-please.hotpop.com> wrote in message
news:ef*************@TK2MSFTNGP15.phx.gbl... Hallo Oskar,
I think Convert.ToChar as well as (char)65 assume the Unicode encoding, while the author has explicitly mentioned the ASCII one. Yes, the character codes of the capital 'A' are the same in both of the encodings, but this, in general, might be not true for other character
codes and other encodings.
Interesting read on the subject of character encoding: http://www.joelonsoftware.com/articles/Unicode.html
"Oskar Punz" <da***************@utanet.at> wrote in message
news:OG**************@TK2MSFTNGP15.phx.gbl... Hi!
<Dmytro Lapshyn [MVP]> schrieb...
Hallo Oskar,
I think Convert.ToChar as well as (char)65 assume the Unicode encoding, while the author has explicitly mentioned the ASCII one. Yes, the character codes of the capital 'A' are the same in both of the encodings, but this, in general, might be not true for other character codes and other encodings.
AFAIK the first 128 Unicode characters are the same as the ASCII characters (except an extra leading zero byte).
So as long as you don't use values above 127 nothing can go wrong. Right?
Ciao
Oskar
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Anibal David Acosta F. |
last post by:
I use C# and need to get the ASCII code of a 8bit character.
When I use the Convert.ToByte() function, it throw an error when the
character is above the 127, for example the char: Ñ
The...
|
by: keithb |
last post by:
How can I convert an ascii code into a character using C# in ASP.NET?
Thanks,
Keith
|
by: many_years_after |
last post by:
Hi,everyone:
Have you any ideas?
Say whatever you know about this.
thanks.
|
by: Tor Inge Rislaa |
last post by:
Replacing character with ASCII code (HTML)
Is it possible to replace a given character or symbol with it's ASCII code
within a <ptag in HTML code.
TIRislaa
|
by: ianenis.tiryaki |
last post by:
i couldnt figure out how i am supposed to find the ASCII code is there
any way to do it? and main problem is i am not sure so i wanted to ask
is it going to display 'a' ? am i right?
What is...
|
by: 0310889 |
last post by:
I am doing my honours project at uni and have to use C programming and
the IIC bus, not the best combination as I have never done that much
programming and I had never heard of the IIC bus! Anyway,...
|
by: tedpottel |
last post by:
Hi,
Newbe needs help,
How can I convert a ascii code to a charter??
-Ted
|
by: Maj |
last post by:
Hello!
Even i've read smth about this in this forums.. i still have problems with getting the ascii code of a character.
here is my problem
I have a string with characters. I have another int...
|
by: pavanponnapalli |
last post by:
hi,
how can i change a character into its equivalent ascii code?
I have used ascii(char) function, but i has not worked.
cheers,
pavan
|
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...
|
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...
|
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,...
|
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$) {
}
...
|
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...
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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: 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...
| |