Check out Scrivo

Do you want to try out Scrivo? Then here's a demo for you that does not just get your feet wet but lets you plunge right in.

Contact us

For more information, please contact us. We're happy to help you out!

Next Sep 29 Previous

Item 547240

What does the following code print in your browser.

<?php
header("Content-type: text/html; charset=windows-1252");
echo "'&#32593;&#31449;' in Chinese translates to 'web site'.";
?>

A: Garbled data because the multibyte UTF-8 characters are rendered as single byte windows-1252 codepage characters.
B: '网站' in Chinese translates to 'web site'.
C: '网站' in Chinese translates to 'web site'.
D: '□□' in Chinese translates to 'web site'.

Answer

The content will be interpreted by the browser as HTML and it will use the windows-1252 character set to render fancy characters (those with the high bit set). However there is not a single strange character in the output string: they are all plain 7 bit ASCII characters. So garbled data cannot be one of the options.

The character sequences "网" and "站" are simply the numeric character references for the Chinese characters "网" and "站". So as long as an encoding was used that is compatible with ASCII the two Chinese characters are always printed out correctly. The windows-1252 character set is compatible with ASCII and therefore answer C is correct.

Answer B is what would have been printed out if the Content-type was set to text/plain.

If your answer is D I'm very sorry for you. It looks like you're using IE and I'm afraid you'll have to send another check to Redmond for a language upgrade pack.