Wednesday, 15 February 2012

encoding - StrConv() corrupting strings on Windows 2008 server -



encoding - StrConv() corrupting strings on Windows 2008 server -

i'm trying migrate web application windows 2008 vps dedicated windows 2008 vps ( both 32bit edition ). problem noticed ( , i've fighting more 24 hours of ) of text comes in garbled form ( , ruins of application ). app works this: (html+js) -> php -> vb6 dll -> reply.

initially thought must issue encoding , iis think not case. narrowed downwards problem this:

when functions of .dll called, string parameters of functions first parsed , translated vb6 proper format:

public function getcorrectstringnotrans(byval strword string) string if strword <> "" if isutf8 = false strword = trim$(strword) else open "c:\log.txt" output #1 dim lol integer lol = 1 len(strword) print #1, "bef:" & lol & ":" & mid$(strword, lol, 1) & ":" & ascw(mid$(strword, lol, 1)) & ":" & asc(mid$(strword, lol, 1)) next lol strword = strconv(strword, vbfromunicode) lol = 1 len(strword) print #1, "aft:" & lol & ":" & mid$(strword, lol, 1) & ":" & ascw(mid$(strword, lol, 1)) & ":" & asc(mid$(strword, lol, 1)) next lol indata = strword dim c new crc dim lll long lll = ubound(indata) print #1, c.crc32(indata, lll) close #1 strword = trim$(convertutf8bytestostring(indata)) '''strword = replace$(trim$(convertutf8bytestostring(indata)), "\'", "'") end if end if getcorrectstringnotrans = strword end function

so in live machine 1 ( current one, works ) output specific string ( lastly number crc check ) :

bef:1:Ξ:926:206 bef:2:Ί:906:186 bef:3:Ξ:926:206 bef:4:±:177:177 bef:5:Ξ:926:206 bef:6:»:187:187 bef:7:Ο:927:207 bef:8::140:140 bef:9:Ο:927:207 bef:10:‚:8218:130 aft:1:?:-17714:63 aft:2:?:-20018:63 aft:3:?:-17458:63 aft:4:?:-29489:63 aft:5:?:-32049:63 1958248078

but in new machine output is:

bef:1:Ξ:926:206 bef:2:Ί:906:186 bef:3:Ξ:926:206 bef:4:±:177:177 bef:5:Ξ:926:206 bef:6:»:187:187 bef:7:Ο:927:207 bef:8::140:140 bef:9:Ο:927:207 bef:10:‚:8218:130 aft:1:?:16191:63 aft:2:?:-20161:63 aft:3:?:-17601:63 aft:4:?:16191:63 aft:5:?:-32193:63 523875602

so ascw() shows string gets messed after strconv() in new machine i'm trying migrate to.

i have triple-checked settings in command panel -> regional , language options , settings same in both machines:

formats tab: current format: greek

location tab: current location: greece

administrative tab: language non-unicode programs: greek

then thought maybe it's issue sp2, because correctly working machine sp2, , 1 i'm experimenting sp1, updated alas, no results.

i don't understand why strconv() doesn't work should. maybe i'm missing in settings or installation. ideas highly appreciated.

p.s. works correctly in windows xp development machine iis5.

you seem misunderstanding encoding.if you're passed string via com, unencoded , "raw" unicode (ucs-2) string. if you're beingness passed in utf-8 can not store in string until it's been decoded otherwise corrupted. must read non ansi info byte array , decode appropriate.

vb6 has no native back upwards utf-8. strconv() vbunicode , vbfromunicode converting between byte arrays containing ansi/mbcs info vb strings in ucs-2.

in summary, assuming correctly beingness passed strings via com, entire function can replaced trim$().

encoding character-encoding vb6 windows-server-2008 codepages

No comments:

Post a Comment