Inline utf8


#1

Blockquote
echo ‘< meta charset=“utf-8” >’;
$French_string=‘pensée’;
$French_string=substr($French_string, 1);
echo $French_string;

I have the code above. and it produces the following

Blockquote
ensée

if I remove the meta charset=“utf-8” in the above, the result output “ensée” will be broken like the below.

Blockquote ens챕e

I like to remove the meta charset=“utf-8”. and I like to use “utf8” in the line only instead of influencing all lines in the page.

The would-be code below doesn’t work correctly, but it, i hope, shows what I want.

Blockquote
$French_string=‘pensée’;
$French_string=substr($French_string, 1. ‘utf-8’);
echo $French_string;

How can I make it produce “ensée” without broken character with removing “<;meta charset=“utf-8”>” in the head of the code?


#2

Instead of creating your own hack, how about sticking to established standards.

Always declare the encoding of your document using a meta element with a charset attribute, or using the http-equiv and content attributes (called a pragma directive). The declaration should fit completely within the first 1024 bytes at the start of the file, so it’s best to put it immediately after the opening head tag.
https://www.w3.org/International/questions/qa-html-encoding-declarations

Suggested Reading
https://www.w3.org/International/questions/qa-what-is-encoding


#3
  1. store all involved files as UTF8 without BOM in your IDE
  2. set the UTF8 header within PHP
  3. use the meta-declaration with UTF8