Skip to content

Commit f3254a0

Browse files
committed
Fix unsafe conversion from Char to int
It is not safe to convert from Char to int16, since the unicode code points are unsigned 16-bit integers. The safe conversion it to int32, as also indicated in the docs.
1 parent 32da47c commit f3254a0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Rubberduck.Parsing/VBA/Extensions/StringExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public static string ToVbExpression(this string managed, bool useConsts = true)
148148
var literal = string.Empty;
149149
foreach (var character in managed.ToCharArray())
150150
{
151-
var unicode = Convert.ToInt16(character) > byte.MaxValue;
151+
var unicode = Convert.ToInt32(character) > byte.MaxValue;
152152
var specialCased = VbCharacterConstants.ContainsKey(character);
153153
if (specialCased || char.IsControl(character) && !unicode)
154154
{

0 commit comments

Comments
 (0)