Got an idea for enhancing SpiderBasic? New command(s) you'd like to see?
Dirk Geppert
Posts: 330 Joined: Fri Sep 22, 2017 7:02 am
Post
by Dirk Geppert » Mon Jul 08, 2024 10:25 am
The StringByteLength function is required in particular for string processing in memory, such as Base64 encoding and decoding, if the text contains emojis or other Unicode characters.
Code: Select all
Procedure.i StringByteLength(str.s)
Protected n.i
! const encoder = new TextEncoder();
! const byteArray = encoder.encode(v_str);
! // Die Länge des Byte-Arrays entspricht der Anzahl der Bytes, die der String benötigt
! v_n = byteArray.length;
ProcedureReturn n
EndProcedure
txt.s = RSet(txt, 100, Chr(8211))
Debug Len(txt)
Debug StringByteLength(txt)
Quin
Posts: 118 Joined: Wed Nov 08, 2023 4:38 pm
Post
by Quin » Thu Jul 11, 2024 5:46 pm
+1
Nice function by the way, it works great. Thanks for introducing me to TextEncoder
juror
Posts: 18 Joined: Fri Aug 01, 2014 4:39 am
Post
by juror » Fri Jul 12, 2024 4:13 am
Another +1
Thanks for sharing