Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polymer does not display cyrillic characters correctly #498

Closed
ujeenator opened this issue May 13, 2014 · 5 comments
Closed

Polymer does not display cyrillic characters correctly #498

ujeenator opened this issue May 13, 2014 · 5 comments

Comments

@ujeenator
Copy link

Hi, I just discovered a problem with cyrillic text in Polymer.

When I use cyrillic text in the polymer element definition, the browser display it like it not understand the encoding.

I found the place in Polymer sources which cause the problem.

Polymer version I used:
0.2.4

File:
/HMTLImports/src/Parser.js

Line:
220

Source code:

function generateScriptDataUrl(script) {
  var scriptContent = generateScriptContent(script), b64;
  try {
    b64 = btoa(scriptContent);
  } catch(e) {
    b64 = btoa(unescape(encodeURIComponent(scriptContent)));
    console.warn('Script contained non-latin characters that were forced ' +
      'to latin. Some characters may be wrong.', script);
  }
  return 'data:text/javascript;base64,' + b64;
}

Description:
When encoding script-string in Base64 data URI, browser don't "undestand" cyrillic symbols.

My solution is to encode script-string with only "encodeURIComponent" function and supply it with "data:text/javascript;charset=utf-8," URI header (instead of "data:text/javascript;base64," header).

Then everything works correctly.

My patch:

function generateScriptDataUrl(script) {
    var scriptContent = generateScriptContent(script), b64;
  try {
    b64 = btoa(scriptContent);
  } catch(e) {
    console.warn('Script contained non-latin characters that were forced ' +
      'to latin. Some characters may be wrong.', script);
    b64 = encodeURIComponent(scriptContent);
    return "data:text/javascript;charset=utf-8," + b64;
  }
  return 'data:text/javascript;base64,' + b64;
}
@ujeenator
Copy link
Author

Do you need a code sample?

@poweif
Copy link

poweif commented Jul 9, 2014

@ebidel
Is this currently being looked at? I'm running into a similar issue with utf8 chinese. Seems like a serious issue in terms of language support.

@poweif
Copy link

poweif commented Jul 9, 2014

+ @sorvell

@ebidel
Copy link
Contributor

ebidel commented Jul 9, 2014

@azakus might also be able to take a look.

@poweif
Copy link

poweif commented Jul 10, 2014

Thanks very much for addressing this so promptly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants