How does PHP internally represent strings?

Posted by Jim Thio on Programmers See other posts from Programmers or by Jim Thio
Published on 2012-06-02T14:41:03Z Indexed on 2012/06/02 22:49 UTC
Read the original article Hit count: 245

Filed under:
|

UTF8?
UTF16?

Do strings in PHP also keep track of the encoding used?

Let's look at this script for example. Say I run:

$original = "??????????????";

What actually happens?

Obviously I think $original will not contain just 7 characters. Those glyphs must each be represented by several bytes there.

Then I do:

$converted = mb_convert_encoding ($original , "UTF-8");

What will happen to $converted? How will $converted be different from $original?

Will it be just the exact same byte sequence as $original but with a different encoding?

© Programmers or respective owner

Related posts about php

Related posts about strings