ChrW - VBScript


Overview

The ChrW command in VBScript converts Unicode character codes to their wide character counterparts. It is primarily used to represent Unicode characters beyond the Basic Multilingual Plane (BMP), which has a limit of 65,535 characters.

Syntax

ChrW(number)

Parameters:

  • number: A Unicode character code in the range 0 to 10FFFF.

Options/Flags

None.

Examples

' Convert the Unicode character code for "heart" (U+2764) to its wide character counterpart
Dim heartWide = ChrW(38404)

Common Issues

  • Using character codes outside the valid range (0 to 10FFFF) will result in an error.
  • Using ChrW in contexts where wide characters are not supported may cause unexpected results.

Integration

ChrW can be used in conjunction with StrConv to convert strings between Unicode and ANSI encodings. For example, the following script converts a string from ANSI to Unicode:

Dim ansiString = "My String"
Dim unicodeString = StrConv(ansiString, vbUnicode)
  • Chr – Converts ANSI character codes to their string counterparts.
  • StrConv – Converts strings between different encodings.