Reputation: 1221
[Edited after the answer below]
I'm fairly new to chrome extension. I'm using various chrome chrome.* apis ( e.g. chrome.tabs ).
E.g. chrome.tabs.onUpdated.addListener( func ) notifies when a tab is updated.
The call back function has Tab object which has various properties to the Title of the tab and URL and other information.
I would like to find out what string encoding does this strings have. The documentation says UTF-8. Documentation link
Does the chrome extension keep the same utf-8 encoding even when the webpage encoding is different ? Is there an chrome API to check for the encoding ?
I ask this because I want to send these strings to a remote process through Native Messaging Host. Pack the data in json string and send it across. It appears I'll have to send the encoding information as well if the encoding depends on web page encoding.
Upvotes: 1
Views: 2569
Reputation: 349002
In the scope of native messaging, you can assume that the strings are UTF-8 encoded, because the the native messaging protocol explicitly states that
The same format is used to send messages in both directions: each message is serialized using JSON, UTF-8 encoded and is preceded with 32-bit message length in native byte order.
The Chrome extension API is generally used with UTF-8. For instance, content scripts will not load if they are encoded in anything else other than UTF-8.
Upvotes: 3