Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Bug in VFP 6.0 on Pan-Chinese NT
Message
From
22/08/2001 05:10:27
 
 
To
21/08/2001 14:26:49
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00546905
Message ID:
00547129
Views:
15
>The following code illustrates a bug in VFP 6.0 on Pan-Chinese NT 4.0 and probably other MBCS NTs. The problem does not occur on U.S. NT. This bug affects Ed Rauh's CLSHEAP library.
>

I think the problem is on Chinese Character.
Previously I see two function in UT, DWordToNum, NumToDWord,
DO the similar calculation.

Well, It should give the same thing if I simple code:

? NumToDWord(DWordToNum(xxx))

I wonder that if one Chinese Dbl-byte word with two single byte can be print but
it can't print the right value if 2 Chinese word as input.
? NumToDWord(DWordToNum([¯º00]))   && correct show
? NumToDWord(DWordToNum([0¯º0]))   && correct show
? NumToDWord(DWordToNum([00¯º]))   && correct show
? NumToDWord(DWordToNum([¯º¯º]))   && incorrect show

*** where input are Zero as dummy inside.

FUNCTION NumToDWord
LPARAMETER tnNum
LOCAL c0, c1, c2, c3
lcResult = REPL(CHR(0), 4)
if tnNum < (2^31 - 1)
   c3 = chr(int(tnNum/ (256^3)))
   tnNum = mod (tnNum, 256^3)
   c2 = chr(int(tnNum/ (256^2)))
   tnNum = mod (tnNum, 256^2)
   c1 = chr(int(tnNum/ (256)))
   c0 = chr(mod(tnNum/ (256)))
   lcResult = c0+c1+c2+c3
ENDIF
RETURN lcResult
ENDFUNC

FUNCTION DWordToNum
LPARAMETER tcDWORD
   local ln0, ln1, ln2, ln3
   ln0 = ASC(SUBSTR(tcDWORD, 1, 1))
   ln1 = ASC(SUBSTR(tcDWORD, 2, 1)) * (256)
   ln2 = ASC(SUBSTR(tcDWORD, 3, 1)) * (256^2)
   ln3 = ASC(SUBSTR(tcDWORD, 4, 1)) * (256^3)
   RETURN ln3+ln2+ln1+ln0
ENDFUNC
>
>* the following fails on pan-chinese win nt 4.0 sp 5
>* VFP 6.0 sp 5 ver. 06.00.8961.00
>lowbyte = 192
>hibyte = 63
>word = chr(lowbyte) + chr(hibyte)
>? "l",asc(substr(word, 1, 1)) && 192 - correct
>? "h",asc(substr(word, 2, 1)) && 63 - correct
>? "w",asc(substr(word, 1, 1)) + asc(substr(word, 2, 1)) * 256 && 16320 - correct
>? "fWORDToNum1", fWORDToNum1(word) && 65342 - wrong
>? "fWORDToNum2", fWORDToNum2(word) && 65342 - wrong
>wait
>
>function fWORDToNum1
>	*Take a binary WORD (16 bit USHORT) and convert it to a VFP Numeric
>	lparameter tcWORD
>	return asc(tcWORD) + bitlshift(asc(substr(tcWORD, 2, 1)), 8)
>endfunc
>
>function fWORDToNum2
>	*Take a binary WORD (16 bit USHORT) and convert it to a VFP Numeric
>	lparameter tcWORD
>	return asc(tcWORD) + asc(substr(tcWORD, 2, 1)) * 256
>endfunc
>
The weak wait for chance, The strong bid for chance,
The clever notch up chance, but The merciful give you chance.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform