Does getCharCount take Unicode sizing into account?

Posted by Phil_M on 24-Nov-2009 15:57

(the following is a copy of a post that I did on the Sonic community area, and it was suggested that it would be more appropriate if posted here ...)


Hi all,

It appears as if the sonicMQ / 4GL adapter function getCharCount doesn't take Unicode sizing into account for text messages, although I don't know that for sure yet.

I've found that if I size a memptr based on it, then load it up using successive putstring functions in a getTextSegment loop, I end up with an error message (Cannot PUT past the end of the MEMPTR. (4791) ) when receiving a message containing double-byte characters (e.g. those in the 128-255 ASCII range or other e.g. Chinese).  As a test, if found that if the message contains 4 Chinese characters (amongst other regular 1-127 ASCII), I find that if I increase the memptr size by 8 then the error goes away, but add 7 and it remains (i.e. each Chinese character probably takes up 3 bytes, so need 4 x 3 = 12 bytes instead of 4 bytes, therefore an extra 8 sorts it out).

If this is correct i.e. that it doesn't take Unicode / double-byte (or more) characters into account, then can another function be used instead?  Alternately, can I pass it an argument such as "RAW" (as with LENGTH() etc. functions) or otherwise?

I am aware that using a bytesmessage gets around this, but I would like to find a solution for textmessage as we would like to keep an option we currently have that allows our clients to select which kind of message types they want to use.

Any assistance or comments on this would be much appreciated.


p.s. this is my 1st post here ... I hope it was clear enough (and you could understand the Aussie accent!)

All Replies

Posted by Håvard Danielsen on 25-Nov-2009 08:35

I'm pretty sure it does not and that there is no alternative function. I suggest you contact Support to confirm this and discuss with them whether this is a known limitation or bug. 

This thread is closed