Unicode?
vining
Posts: 4,368
I was about to implement unicode capability into a module I'm working on so I went to the iPort module v_3_21 which I know uses it and since it's already in my system I figured I'd use it for reference.
Anybody got a clue? Is this just an error in the module? I don't recall ever noticing any problems with displayed text but.....
DEFINE_CONSTANT WC_FORMAT_UTF8 = 3 //Unicode format type WC_FORMAT_TP = 100 //Unicode format type for panels DEFINE_FUNCTION fnSEND_VTEXT (DEV iTP,nCHAN,CHAR strMSG[]) //All variable text to panel is sent thru this function { STACK_VAR WIDECHAR strSTRING1[600] STACK_VAR CHAR strSTRING2[600] STACK_VAR INTEGER iTEXT strSTRING1 = WC_DECODE(strMSG,WC_FORMAT_UTF8,1) ; // Used to Decode strSTRING2 = WC_ENCODE(strSTRING1,WC_FORMAT_TP,1) ;//WC_TP_ENCODE (strSTRING1) should be the same //SEND_STRING 0,"'R4 Device_ID = ',ITOA(DEVICE_ID(dvTPArry[3]))" //R4 Device is 322 IF(DEVICE_ID(iTP) < 256) //Is it a G3 Panel in the array? {....................I first went to the function that uses it and noticed the constants so I went to the constants to see what values they held. I then went to the help section of NS to read about them and found this:
So why if the instruction says WC_FORMAT_TP is defined as a value of 4 does the module define WC_FORMAT_TP in the constant section as 100?Format:
1 Unicode Encode the data as a Unicode formatted stream. The constant WC_FORMAT_UNICODE is defined as a value of 1 for specifying this format.
2 Unicode BE Encode the data as a Unicode BE (Big Endian) formatted stream. The constant WC_FORMAT_UNICODE_BE is defined as a value of 2 for specifying this format.
3 UTF-8 Encode the data as a UTF-8 formatted stream. The constant WC_FORMAT_UTF8 is defined as a value of 3 for specifying this format.
4 TP Encode the data for use with the UNI TP command. The constant WC_FORMAT_TP is defined as a value of 4 for specifying this format.
Anybody got a clue? Is this just an error in the module? I don't recall ever noticing any problems with displayed text but.....
0
Comments
You also need an #include to untilize the Unicode.axi in your modules but I haven't checked to see if it's pulled in automatically to the main code. I would have thought the unicode functions would be system functions but they're not. In the 2 modules that have the Unicode I have: defined in my modules and they are also defined in the #inlcuded Unicode.axi but the iPod module compiles w/o errors but the module I'm working on now has: I then noticed that in my module I had: to match the help file, the iPod module still had: So my module through an error because this constant was defined more than once with different values while the iPod module was defined more than once with the same value.
I guess that means you can defined a constant as many times as you want as long as the value is "constant" or the same?
I think who ever wrote the iPod module defined these 2 constants in the constant secton because the include was added in define start and the functon which used the constants got compiled before the include was pulled in and that through an error saying they weren't defined. As long as the constants have the same value the compiler doesn't seem to care but as soon as you change one value the compiler will throw an"already defined err".
Makes ya go Hmmm?