From 56ecf146be743312716c9c0a5e402799625f96d9 Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 12 Oct 2011 08:13:48 +0000 Subject: [PATCH] compiler: fix error in length retrieving during the unicode to utf8 conversion git-svn-id: trunk@19475 - --- compiler/ncon.pas | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/compiler/ncon.pas b/compiler/ncon.pas index 39cd96ae96..cfaaa33660 100644 --- a/compiler/ncon.pas +++ b/compiler/ncon.pas @@ -1008,9 +1008,10 @@ implementation if (cp1=CP_UTF8) then begin pw:=pcompilerwidestring(value_str); - l:=UnicodeToUtf8(nil,PUnicodeChar(pw^.data),0); + l2:=len; + l:=UnicodeToUtf8(nil,0,PUnicodeChar(pw^.data),l2); getmem(pc,l); - UnicodeToUtf8(pc,l,PUnicodeChar(pw^.data),getlengthwidestring(pw)); + UnicodeToUtf8(pc,l,PUnicodeChar(pw^.data),l2); len:=l-1; donewidestring(pw); value_str:=pc; @@ -1071,7 +1072,7 @@ implementation initwidestring(pw); setlengthwidestring(pw,len); ascii2unicode(value_str,len,cp2,pw); - l:=UnicodeToUtf8(nil,PUnicodeChar(pw^.data),0); + l:=UnicodeToUtf8(nil,0,PUnicodeChar(pw^.data),len); if l<>len then ReAllocMem(value_str,l); len:=l-1;