Hi,
There is a string in unicode. The length of Latin characters is 1 byte, the length of characters of other code pages is 2 bytes.
How to get an array of characters of this string ?
#include "fivewin.ch"
function Main()
local cString := HEXTOSTR( "41C39CC49EE0B095" )
local nChars, n
local aChars := {}
? cString // --> AÜĞక
? "Length in Bytes : ", Len( cString ) // --> 8
? "Length in Chars : ", nChars := HB_UTF8LEN( cString ) --> 4
for n := 1 to nChars
aAdd( aChars, HB_UTF8SUBSTR( cString, n, 1 ) )
next
XBROWSER aChars // { "A", "Ü", "Ğ", "క" }
AEval( aChars, { |c,i| aChars[ i ] := { c, STRTOHEX( c ), Len( c ) } } )
XBROWSER aChars SETUP oBrw:cHeaders := { "CHAR","HEX","BYTES" }
return nil
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 68 guests