dotnet / dotnet/vblang

(Documentation) Bug: AscW(ChrW(x)) <> x

Open
#509 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
328
Forks
71
PR merge metrics
No merged PRs in 30d

Description

Form the documentation (https://docs.microsoft.com/en-us/dotnet/api/microsoft.visualbasic.strings.chrw?view=netframework-4.8):

> Returns the character associated with the specified character code.
> public static char ChrW (int CharCode);
> Parameters
> CharCode
> Int32
> Required. An Integer expression representing the code point, or character code, for the character.
> Returns
> Char
> The character associated with the specified character code.
> Exceptions
>
> ArgumentException
> CharCode < -32768 or > 65535 for ChrW.

And AscW is the opposite of that.
That means that AscW(ChrW(x)) = x

So, the range to check is -32678 to 65535
Test code:

```
Public Function test() As Integer
For i As Integer = -32768 To 65535
If i <> Microsoft.VisualBasic.AscW(Microsoft.VisualBasic.ChrW(i)) Then
Return i
End If
Next
Return -99999
End Function
```

And this test function fails for **every** negative input.
All positive input (and zero) works fine.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.