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

International symbols in JSX #4267

Closed
enaqx opened this issue Jul 2, 2015 · 13 comments
Closed

International symbols in JSX #4267

enaqx opened this issue Jul 2, 2015 · 13 comments

Comments

@enaqx
Copy link
Contributor

enaqx commented Jul 2, 2015

I've experimented with international symbols inside react component and it failed on simple example. Is it by design behaviour?

      var HelloWorld = React.createClass({
        render: function() {
          return (
            <p>
              的なことは, <input type="text" placeholder="Введите ваше имя" />!
              Время: {this.props.date.toTimeString()}
            </p>
          );
        }
      });

      setInterval(function() {
        React.render(
          <HelloWorld date={new Date()} />,
          document.getElementById('example')
        );
      }, 500);

And get

image

Despite that on JSFiddle it works like charm

I've tried this on OS X with sublime and webstorm. Both work like on image.

@iamdustan
Copy link
Contributor

Check what character encoding your serving your page with. It should likely be UTF-8

@jimfb
Copy link
Contributor

jimfb commented Jul 2, 2015

I think failing to support international characters is not by design :P.

I just tested on jsfiddle and in one of the files in the examples directory, it seemed to work fine. This seems to imply to me that it's not a React issue. Are you sure you have the page encoding set correctly for your test? Try something like <meta charset="UTF-8">. Can you provide a complete testcase / steps to repro?

@enaqx
Copy link
Contributor Author

enaqx commented Jul 2, 2015

Yeahh. I've added meta and it works now. I assume on translation docs its better to add <meta charset="UTF-8"> in all examples even if it is not present in original example.

@jimfb
Copy link
Contributor

jimfb commented Jul 2, 2015

Yeah, that seems reasonable to me. Any example containing non-ascii characters should probably have the meta tag.

On a related note: Might also want the meta tag on the english versions (for consistency, if nothing else). Encourage the best-practice of always specifying your encoding. But I'll let @spicyj and @zpao be the gatekeepers of that decision.

@enaqx
Copy link
Contributor Author

enaqx commented Jul 2, 2015

@jimfb, agree on that. For consistency its better to add charset meta everywhere to resolve future confusions.

@sophiebits
Copy link
Collaborator

I guess I'm okay with that, though in reality what charset you use for your HTML files is your own business and React doesn't really care. 99% of people probably do want utf-8 though so we can add it.

@jimfb
Copy link
Contributor

jimfb commented Jul 8, 2015

cc @tako-black

@bgw
Copy link
Contributor

bgw commented Jul 8, 2015

<meta charset="UTF-8" /> works, although it's a far worse solution than using the correct HTTP headers. Without the HTTP header, browsers have to examine the first few kilobytes of the page, guess the charset from the character frequency, then start parsing with that guess. If it encounters a <meta charset="blah" /> tag, and realizes it got the charset wrong, it has to stop and reparse the entire page.

If we're going to make a suggestion about defining a charset, we should suggest the appropriate HTTP headers. The meta tag is buggy and has horrible perf characteristics.

@jimfb
Copy link
Contributor

jimfb commented Jul 8, 2015

@bgw Users run into this when opening local html files, which don't have server headers. But yes, I agree. That said, anyone who knows how to set a server header will know to remove the meta tag from their markup :P. The point is to solve the problem where someone opens a local translated example and it blows up.

@kohei-takata
Copy link
Contributor

@jimfb
What should I do?
Should I change some Japanese documents?

@jimfb
Copy link
Contributor

jimfb commented Jul 9, 2015

@tako-black Yep, if you want, any inline example in the translated documents that renders a full HTML markup (like the first code block example on http://facebook.github.io/react/docs/getting-started.html) should probably contain <meta charset="UTF-8" /> in the header.

Was cc'ing you mostly so you had context and were aware of the issue, since it primarily affects translations.

@kohei-takata
Copy link
Contributor

@jimfb
OK. I understand.
I'll make PR that add the tag in the header of HTML.

@berkerpeksag
Copy link

Already fixed in 87ecb0b (PR #4334) This can be closed now.

@zpao zpao closed this as completed Sep 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants