mIRC Homepage
Posted By: FroggieDaFrog Get length of unicode text in bvar - 24/05/21 11:45 AM
I have a &bvar that contains unicode/utf-8 text, is there a way to get the length of text; that is the number of characters without having to loop over its entirety examining chunks of text
Posted By: maroon Re: Get length of unicode text in bvar - 24/05/21 01:37 PM
Assuming it's valid UTF8 already:

//var -sp %a t $+ $chr(233) $+ st $+ $chr(10004) $+ $chr(32) , %b $utfencode(%a) , %c $len(%b)

result: * Set %c to 9
Posted By: FroggieDaFrog Re: Get length of unicode text in bvar - 24/05/21 02:07 PM
The issue I'm having is that the data is in a &bvar and its larger than mIRC's LLL
Posted By: maroon Re: Get length of unicode text in bvar - 24/05/21 05:25 PM
In this case you might need to use $bvar(&binvar,N,M).text where each subsequent N is M+1, and each M is calculated by jumping ahead $maxlenl bytes then finding the next byte value that's not in the 128-191 range.
© mIRC Discussion Forums