Jump to content
php.lv forumi

strLen() skaita stringa garumu nepareizi


daGrevis

Recommended Posts

Sveiki,

Problēma veca kā pasaule, bet tas, ko no galvas atcerējos un izdarīju, nedeva vēlamos rezultātus.

Lūk, šī koda rindiņa izvada 8, bet, protams, pareizā atbilde būtu 4... =P

 

<?= strLen('āāāā'); ?>

 

Tad nu Es mēģināju šādi, bet, diemžēl bez rezultātiem... =(

 

mb_internal_encoding('UTF-8');
mb_http_output('UTF-8');

 

Idejas? =P

Edited by daGrevis
Link to comment
Share on other sites

pa visam vienkāršāk:

ANSI viens simbols = 1b

UTF-8 viens simbols = 1b

UTF-8 viens simbols ar garumzīmi = 2b

:

"UTF-8 encodes each character (code point) in 1 to 4 octets (8-bit bytes). The first 128 characters of the Unicode character set (which correspond directly to the ASCII) use a single octet with the same binary value as in ASCII."

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...