Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Who does the conversion on copy/paste?

Suppose I have an input field in a web page with charset UTF8; suppose I open a text file encoded with ISO-8859-1 as charset.

Now I copy and paste a string with special characters (like, for example, ô) from file to the input field : I see that the special characters is correctly displayed into input field.

Who does the conversion from ISO-8859-1 to UTF8? The browser?

like image 707
markzzz Avatar asked Apr 26 '11 22:04

markzzz


2 Answers

When you open the file and copy/paste it to the browser, it ends up in Unicode, as that is what the browser's UI controls use internally. Who actually performs the conversion from ISO-8859-1 to Unicode depends on a few factors (what OS you are using, whether your chosen text editor is compiled to use Ansi or Unicode, what clipboard format(s) - CF_TEXT for Ansi, CF_UNICODETEXT for Unicode - the app uses for the copy, etc). But either way, when the web browser submits the form, it then encodes its Unicode data to the charset of the HTML/form during transmission.

like image 131
Remy Lebeau Avatar answered Sep 20 '22 01:09

Remy Lebeau


In all likelihood, it's not really converted to UTF-8, but instead to the internal representation of characters used by the browser, which is quite likely to be UTF-16 (no matter what the encoding of the web page is).

like image 26
Simon Nickerson Avatar answered Sep 21 '22 01:09

Simon Nickerson