I am not familiar with the functions that you are using. Please post a complete working program so that we can run your example. This will tell us what modules you are using and allow us to read their documentation. Good Luck, Bill

sorry, the complete program is big and in many files. I am trying to reduce the size of string variable. there is a hard limit. problem is, string uses utf8 or something, so it might end with bad encoding if its simply cut. so I stripped char by char, to get within limit. thanks.

You would have to check that with your specific encoding, but if you use the utf8 module, the substr function should not cut your string in the middle of a multibyte character (at least, I think so, I did not try).