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

Incorrect display of extended unicode characters with text() and println() #701

Closed
golanlevin opened this issue May 30, 2015 · 3 comments
Closed

Comments

@golanlevin
Copy link

Unicode characters in output should resemble Unicode characters in input, but currently don't.

I wanted to display the degree symbol (°, U+00B0) in a p5.js canvas, using the text() command. Pasting the symbol into code in the IDE presented no problem. However, the symbol does not display correctly, whether on the canvas or in the console:

var foo =  "It is 30° outside";
text (foo, 20,20); 
println (foo);

This produces the result:

It is 30° outside

A provisional fix was to use the Javascript Unicode representation for the degree symbol, '\xB0'. However I think this will really trap novice programmers.

  var foo = "It is 30\xB0 outside";
  text(foo, 20, 20);
  println(foo);
@workergnome
Copy link
Contributor

I have also seen this—at least for me, it seemed to happen when running locally, but not when running on a server.

Not sure why, but that's another area to explore?

@workergnome
Copy link
Contributor

Got it.

  <meta charset="UTF-8">

needs to be added to the default sketch HTML for this to work.

@workergnome
Copy link
Contributor

@lmccart fixed this in the deploy/release code—it will appear in the next released version of p5.js.

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

2 participants