Mojtaba Rezaeian
Mojtaba Rezaeian

Reputation: 8756

What is the difference between Asc() and AscW()?

What is the difference between Asc and AscW in vb.net? I have similar question about Chr() and ChrW() functions too! Is there any benefits for using them with or without W suffix?!

Upvotes: 4

Views: 7696

Answers (1)

Trevor
Trevor

Reputation: 8004

Unicode is a standard that is designed to replace the ANSI standard for encoding characters in a numeric form. Because the ANSI standard only uses a single byte to represent each character, it is limited to a maximum of 256 different characters. While this is sufficient for the needs of an English speaking audience, it falls short when the worldwide software market is considered. With the Unicode standard, each character is represented by two bytes, so that the entire Unicode character set includes 65,536 possible locations.

Microsoft Windows NT, Microsoft Windows 2000, and Microsoft OLE 2.0 are entirely Unicode based, and Visual Basic (4.0 and higher) represents all strings internally in Unicode format. The AscW and ChrW functions allow access to the full range of Unicode characters. These functions work in the same way as the original Asc and Chr functions except that they support arguments from 0 to 65,535 instead of just from 0 to 255. Many Visual Basic objects (such as the debug window and the label and text box) return a "?" when these objects do not know how to display an Unicode character.

Please read more here about this (it's the official article from Microsoft; their link is now dead)

Upvotes: 4

Related Questions