What is really happening when we change encoding in a string?

Posted by Jim Thio on Programmers See other posts from Programmers or by Jim Thio
Published on 2012-06-01T05:53:48Z Indexed on 2012/06/01 10:49 UTC
Read the original article Hit count: 370

http://php.net/manual/en/function.mb-convert-encoding.php

Say I do:

$encoded = mb_convert_encoding ($original);

That looks like simple enough. WHat I am imagining is the following

$original has a pointer to the way the string is actually encoded. Something like char * kind of thing. And then there are things like what the character actually encoded.

It's probably somewhere along UTF-64 kind of thing where each glyph is indeed a character.

Now when we do

$encoded = mb_convert_encoding ($original); 

several thing can happen:

  • the original internal representation doesn't change however it is REINTERPRETED so that the code that show up differs
  • the original string that it represent doesn't change however the ENCODING change.

Which one is right?

© Programmers or respective owner

Related posts about php

Related posts about character-encoding