fixes #8468, stdlib.encodings.convert not crash anymore on windows (#8470)

This commit is contained in:
andri lim
2018-07-30 17:04:49 +07:00
committed by Andreas Rumpf
parent 6b40114f21
commit 2e6d073be1
2 changed files with 25 additions and 4 deletions

View File

@@ -0,0 +1,21 @@
discard """
output: '''OK'''
"""
#bug #8468
import encodings, strutils
when defined(windows):
var utf16to8 = open(destEncoding = "utf-16", srcEncoding = "utf-8")
var s = "some string"
var c = utf16to8.convert(s)
var z = newStringOfCap(s.len * 2)
for x in s:
z.add x
z.add chr(0)
doAssert z == c
echo "OK"