473,809 Members | 2,940 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASCII code

I want to get characters for given ascii codes. Dont wanna use the CHR or
ChrW functions. What r the .NET equivilents of the Chr & ChrW functions?

Regards,

Abubakar.
Nov 20 '05 #1
39 2579
Cor
Hi Abukar,

The Chr and the ChrW are normal functions in the Net the same as the + the +
and the =.

Why would do you not want to use those?

Cor
Nov 20 '05 #2
"Abubakar" <em**********@y ahoo.com> schrieb
I want to get characters for given ascii codes. Dont wanna use the
CHR or ChrW functions. What r the .NET equivilents of the Chr & ChrW
functions?


system.text.enc oding.ascii.get string

Note that ascii = 7 bits.

--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3
Cor
Hi Armin,
Now I never get the answer from Akubar,
:-(
Cor
system.text.enc oding.ascii.get string

Note that ascii = 7 bits.

Nov 20 '05 #4
"Cor" <no*@non.com> schrieb
Hi Armin,
Now I never get the answer from Akubar,
:-(


When I answered, your answer was not here, yet. For ASCII values, chr/chrw
don't help anyway.
--
Armin

Nov 20 '05 #5
> Why would do you not want to use those?

because they require a reference to microsoft.visua lbasic.dll, and I dont
use that. I always program by removing its reference from project "imports".
I dont use anything that comes from the vb dll. Like for example, instead of
using the old mid function I'll use the substring function of the string
class. Wanna b more close to .net that the language.

"Cor" <no*@non.com> wrote in message
news:eP******** ******@TK2MSFTN GP09.phx.gbl... Hi Abukar,

The Chr and the ChrW are normal functions in the Net the same as the + the + and the =.

Why would do you not want to use those?

Cor

Nov 20 '05 #6
Abubakar,
You do realize that ChrW is inlined as IL by the VB.NET compiler, if you
give it an integer constant? Which means that you can use ChrW with Char &
String Constants!

It only calls into microsoft.visua lbasic.dll if you give it a variable
parameter!

Of course you need to import the namespace in either case.

Initial tests suggest that AscW is always inlined for chars! And is only
calls microsoft.visua lbasic.dll for String variables.

If you don't believe me check the IL produced with ILDASM.EXE.

I would recommend using ChrW! Seems a little naive to avoid ALL the
functions in Microsoft.Visua lBasic, especially considering ALL the functions
are valid .NET!!! Usable from C# & other .NET languages as equally well as
VB.NET! Hell! its even installed as part of the framework itself!

Hope this helps
Jay

"Abubakar" <em**********@y ahoo.com> wrote in message
news:OC******** ******@TK2MSFTN GP12.phx.gbl...
Why would do you not want to use those?

because they require a reference to microsoft.visua lbasic.dll, and I dont
use that. I always program by removing its reference from project

"imports". I dont use anything that comes from the vb dll. Like for example, instead of using the old mid function I'll use the substring function of the string
class. Wanna b more close to .net that the language.

"Cor" <no*@non.com> wrote in message
news:eP******** ******@TK2MSFTN GP09.phx.gbl...
Hi Abukar,

The Chr and the ChrW are normal functions in the Net the same as the +
the +
and the =.

Why would do you not want to use those?

Cor


Nov 20 '05 #7
On 2004-02-11, Abubakar <em**********@y ahoo.com> wrote:
Why would do you not want to use those?


because they require a reference to microsoft.visua lbasic.dll, and I dont
use that. I always program by removing its reference from project "imports".
I dont use anything that comes from the vb dll. Like for example, instead of
using the old mid function I'll use the substring function of the string
class. Wanna b more close to .net that the language.


Why would you do that? Did you know that the compiler inserts the
reference even if you remove it? There is no reason to remove it.
Those functions are the functions that make vb.net - well vb.net. If
you don't want to use those functions then you might as well be using
C#. If your worried they are going to be removed then, stop worrying.
It is only the functions in Microsoft.Visua lBasic.Compatab ility.dll that
will be removed eventually. Further, there are a lot of handy functions
in the Microsoft.Visua lBasic.dll. In fact, I have added this reference
to a couple of C# projects to use the financial functions since it was
easier then coding them myself :)

About the only functions that I would suggest you avoid from the
standard VB.NET runtime is the File IO functions.... They are wicked
slow...

--
Tom Shelton [MVP]
Powered By Gentoo Linux 1.4
"We are on the verge: Today our program proved Fermat's next-to-last theorem."
-- Epigrams in Programming, ACM SIGPLAN Sept. 1982
Nov 20 '05 #8
Armin,
Actually I understand that Chr uses System.Test.Enc oding.Default, as it
honors your Windows Code Page. However system.text.enc oding.ascii will give
the Ascii characters, which as you state is 7 bit. (I suspect Abubakar may
actually want ANSI characters in a particular code page).

ChrW is suppose to be "Straight Unicode" no encoding involved. Using
ILDASM.EXE on ChrW itself it checks to be certain the 32bit integer is
within "range", then calls Convert.ToChar.

I really don't know why anyone would want to avoid ChrW & AscW personally,
as my other post suggests, they are in-lined by the VB.NET compiler itself
most of the time! In other words VB.NET doesn't even wait for the JIT
compiler to possible inline them, it does it itself!

Hope this helps
Jay

"Armin Zingler" <az*******@free net.de> wrote in message
news:u4******** ******@tk2msftn gp13.phx.gbl...
"Abubakar" <em**********@y ahoo.com> schrieb
I want to get characters for given ascii codes. Dont wanna use the
CHR or ChrW functions. What r the .NET equivilents of the Chr & ChrW
functions?


system.text.enc oding.ascii.get string

Note that ascii = 7 bits.

--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #9
> Why would you do that? Did you know that the compiler inserts the
reference even if you remove it? There is no reason to remove it. well I dont think so, u know Rotor ? Its the open source .net. What I do is
sometimes I compile my programs in vbc and execute them in rotor, they work
fine if the vb dll is not referenced in it. Although I love C# and make
utilities in it but sometimes VB is a must as ordered by my seniors so I
like to program in such a way that I dont want to use vb dll specific
functions. And if I know everything through .NET classes and not by the
language, I'm pretty comfortable programming in any given language as I'v
already told u that I do program in C# and VB.net almost at the same time.
"Tom Shelton" <to*@mtogden.co m> wrote in message
news:#5******** ******@TK2MSFTN GP12.phx.gbl... On 2004-02-11, Abubakar <em**********@y ahoo.com> wrote:
Why would do you not want to use those?

because they require a reference to microsoft.visua lbasic.dll, and I dont use that. I always program by removing its reference from project "imports". I dont use anything that comes from the vb dll. Like for example, instead of using the old mid function I'll use the substring function of the string
class. Wanna b more close to .net that the language.


Why would you do that? Did you know that the compiler inserts the
reference even if you remove it? There is no reason to remove it.
Those functions are the functions that make vb.net - well vb.net. If
you don't want to use those functions then you might as well be using
C#. If your worried they are going to be removed then, stop worrying.
It is only the functions in Microsoft.Visua lBasic.Compatab ility.dll that
will be removed eventually. Further, there are a lot of handy functions
in the Microsoft.Visua lBasic.dll. In fact, I have added this reference
to a couple of C# projects to use the financial functions since it was
easier then coding them myself :)

About the only functions that I would suggest you avoid from the
standard VB.NET runtime is the File IO functions.... They are wicked
slow...

--
Tom Shelton [MVP]
Powered By Gentoo Linux 1.4
"We are on the verge: Today our program proved Fermat's next-to-last

theorem." -- Epigrams in Programming, ACM SIGPLAN Sept. 1982

Nov 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

37
10179
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 accidentally entered are properly represented when the document is served. My programming language allows me to get the ascii value for any individual character so what I am doing when a change is saved is to look at each character in the content and...
2
6207
by: Martín Marconcini | last post by:
Hello there, I'm writting (or trying to) a Console Application in C#. I has to be console. I remember back in the old days of Cobol (Unisys), Clipper and even Basic, I used to use a program (its name i cannot recall now...) where I designed the "screen" using this "program" and then saved it into an ASCII file. (thus, using 'extended' ASCII's like Lines, Corners, etc. and making screens look nicer and more professional). Then reading a...
11
17422
by: Kai Bohli | last post by:
Hi all ! I need to translate a string to Ascii and return a string again. The code below dosen't work for Ascii (Superset) codes above 127. Any help are greatly appreciated. protected internal string StringToAscii(string S) { byte strArray = Encoding.UTF7.GetBytes(S); string NewString = Encoding.UTF7.GetString(strArray);
18
34152
by: Ger | last post by:
I have not been able to find a simple, straight forward Unicode to ASCII string conversion function in VB.Net. Is that because such a function does not exists or do I overlook it? I found Encoding.Convert, but that needs byte arrays. Thanks, /Ger
10
30202
by: Mark Rae | last post by:
Hi, I'm in the process if converting the data out of an old DOS-based SunAccounts system (don't ask!) into SQL Server. The data has been sent to me as a collection of hundreds of SunAccounts backup files and it's a simple (yet extremely laborious!) process of opening each backup file in turn, reading the file line by line, splitting it up into its constituent parts, and then squirting it into SQL Server.
9
4412
by: pamelafluente | last post by:
I have found on the web a post with this useful way to convert (if possible) a ScanCode to Ascii. This is remarkably useful to filter keys under KeyDown/up event. My problem is that I am not familiar with Platform Invoke and this code (vb6) needs just a little adjustment (types) to work in VB.NET. Would anyone be so kind as to show the necessary changes? Thank you very much in advance!!
31
3229
by: Claude Yih | last post by:
Hi, everyone. I got a question. How can I identify whether a file is a binary file or an ascii text file? For instance, I wrote a piece of code and saved as "Test.c". I knew it was an ascii text file. Then after compilation, I got a "Test" file and it was a binary executable file. The problem is, I know the type of those two files in my mind because I executed the process of compilation, but how can I make the computer know the type of a...
7
4039
by: Jeffrey Spoon | last post by:
Hello, I'm a bit stuck trying to convert a text file which contains extended ASCII text and changing the ASCII values so they become readable. I do this by subtracting 127 from the ASCII value. However, at the moment I am just getting more gibberish so I'm probably doing something wrong. I tried using ASCII Encoding before to get the ASCII values. Although this worked for 0-127 ASCII values, extended ASCII gave strange values (such as 1992...
399
12980
by: =?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?= | last post by:
PEP 1 specifies that PEP authors need to collect feedback from the community. As the author of PEP 3131, I'd like to encourage comments to the PEP included below, either here (comp.lang.python), or to python-3000@python.org In summary, this PEP proposes to allow non-ASCII letters as identifiers in Python. If the PEP is accepted, the following identifiers would also become valid as class, function, or variable names: Löffelstiel,...
9
4150
by: =?Utf-8?B?RGFu?= | last post by:
I have the following code section that I thought would strip out all the non-ascii characters from a string after decoding it. Unfortunately the non-ascii characters are still in the string. What am I doing wrong? Dim plainText As String plainText = "tâ•e" Dim plainTextBytes() As Byte Dim enc As Encoding = Encoding.ASCII plainTextBytes = enc.GetBytes(plainText)
0
9722
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9603
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10643
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10391
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10121
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7664
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5550
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4333
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.