mIRC Home    About    Download    Register    News    Help

Print Thread
Get length of unicode text in bvar #268978 24/05/21 11:45 AM
Joined: Apr 2010
Posts: 966
F
FroggieDaFrog Offline OP
Hoopy frood
OP Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 966
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

Last edited by FroggieDaFrog; 24/05/21 02:09 PM.

I am SReject
My Stuff
Re: Get length of unicode text in bvar [Re: FroggieDaFrog] #268981 24/05/21 01:37 PM
Joined: Jan 2004
Posts: 1,585
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,585
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

Re: Get length of unicode text in bvar [Re: maroon] #268982 24/05/21 02:07 PM
Joined: Apr 2010
Posts: 966
F
FroggieDaFrog Offline OP
Hoopy frood
OP Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 966
The issue I'm having is that the data is in a &bvar and its larger than mIRC's LLL


I am SReject
My Stuff
Re: Get length of unicode text in bvar [Re: FroggieDaFrog] #268984 24/05/21 05:25 PM
Joined: Jan 2004
Posts: 1,585
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,585
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.