FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » mysql dynamic binding and pass-by-ref deprecated
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Unicode support [message #180982 is a reply to message #180980] Sat, 30 March 2013 19:18 Go to previous messageGo to previous message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma:
Senior Member
Christoph Becker wrote:

> I am more concerned about the number of characters the string holds.
> Say, I want to get the last character:
>
> $str = '€';
> echo $str[2];
>
>> Because lack of precision in font reproduction, or even in guaranteeing
>> which font may be selected, renders the former an 'open' question.
>>
>> strlen('€')===3 is in fact the correct answer.

That depends on the character encoding of the source code. 3 is the correct
answer for an *UTF-8*-encoded U+20AC EURO SIGN character, which is then
encoded E2 82 AC. [1]

> I suppose most *higher level languages* define the length of a string as
> the number of characters the string holds. Cf. ECMAScript's length
> property and TCL's [string length]. Even PHP's mb_strlen() returns the
> number of characters.

AISB, unfortunately the “length” property of ECMAScript String instances is
not a good example in that regard as it does _not_ mean the number of
characters but the number of 16-bit units (UTF-16 code units, usually).
That is only less obvious than with UTF-8 because all Unicode characters in
the BMP can be encoded using only one such unit. (I am working on a
workaround; you could call it “an mb_strlen() for ECMAScript
implementations”.)


PointedEars
___________
[1] <http://www.rishida.net/tools/conversion/>
--
Danny Goodman's books are out of date and teach practices that are
positively harmful for cross-browser scripting.
-- Richard Cornford, cljs, <cife6q$253$1$8300dec7(at)news(dot)demon(dot)co(dot)uk> (2004)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Need Forex Feed in PHP
Next Topic: can't get includes to load
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 30 16:43:20 GMT 2024

Total time taken to generate the page: 0.04562 seconds