Skip to content

Commit

Permalink
Fix ascii2text encoding (#1648)
Browse files Browse the repository at this point in the history
Co-authored-by: wixoa <[email protected]>
  • Loading branch information
amylizzle and wixoaGit authored Feb 18, 2024
1 parent b048ec4 commit f7ea4c8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
29 changes: 29 additions & 0 deletions Content.Tests/DMProject/Tests/Builtins/text2ascii2text.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/proc/RunTest()
ASSERT(text2ascii_char("abcdéfg",6) == 102) //102 is f
ASSERT(ascii2text(text2ascii("a")) == "a")
var/list/values = list(
"©" = 0x00A9,
"®" = 0x00AE,
"" = 0x203C,
"" = 0x2049,
"" = 0x20E3,
"" = 0x2122,
"" = 0x2139,
"" = 0x231A,
"" = 0x231B,
"" = 0x2328,
"" = 0x23CF,
"" = 0x24C2,
"" = 0x25AA,
"" = 0x25AB,
"" = 0x25B6,
"" = 0x25C0,
"" = 0x2934,
"" = 0x2935,
"" = 0x3030,
"" = 0x303D,
"" = 0x3297,
"" = 0x3299,
)
for(var/v in values)
ASSERT(ascii2text(values[v]) == v)
2 changes: 0 additions & 2 deletions Content.Tests/DMProject/Tests/Builtins/text2ascii_char.dm

This file was deleted.

2 changes: 1 addition & 1 deletion OpenDreamRuntime/Procs/Native/DreamProcNativeRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public static DreamValue NativeProc_ascii2text(NativeProc.Bundle bundle, DreamOb
if (!ascii.TryGetValueAsInteger(out int asciiValue))
throw new Exception($"{ascii} is not a number");

return new DreamValue(Convert.ToChar(asciiValue).ToString());
return new DreamValue(char.ConvertFromUtf32(asciiValue));
}

[DreamProc("block")]
Expand Down

0 comments on commit f7ea4c8

Please sign in to comment.