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

UTF8 characters render differently in the browser than in the console #16800

Closed
DartBot opened this issue Feb 13, 2014 · 11 comments
Closed

UTF8 characters render differently in the browser than in the console #16800

DartBot opened this issue Feb 13, 2014 · 11 comments
Assignees
Labels
needs-info We need additional information from the issue author (auto-closed after 14 days if no response) os-osx

Comments

@DartBot
Copy link

DartBot commented Feb 13, 2014

This issue was originally filed by jcbritob...@gmail.com


What steps will reproduce the problem?

  1. Convert a data with utf-8 charset to json - Ex: List<String> list = JSON.decode('[{"nome":"alícia"}]');
  2. Print the data on html or console output

What is the expected output? What do you see instead?
in console or html page the correct charset - alícia

What version of the product are you using? On what operating system?
Dart SDK 1.1.3 in MAC OSX Mavericks


Attachments:
table.html (484 Bytes)
table.dart (1.02 KB)

@kevmoo
Copy link
Member

kevmoo commented Feb 13, 2014

I tried this in the console and the input string matches the round-trip string. (See sample code at the bottom.)

This may have to do with how the browser handles special characters when test as text.

I attached a screen shot of running the sample through an html page. I then copy-pasted the encoded output to the Javascript console. Some weird discrepancies.

*** sample ***

import 'dart:convert';

void main() {
  var input = '[{"nome":"alícia"}]';
  List<String> list = JSON.decode(input);
  print(list);

  var encoded = JSON.encode(list);
  print(encoded);

  print(input == encoded);
}


Attachment:
[Screen Shot 2014-02-13 at 8.33.41 AM.png](https://storage.googleapis.com/google-code-attachments/dart/issue-16800/comment-1/Screen Shot 2014-02-13 at 8.33.41 AM.png) (11.04 KB)


Added Library-Html, Triaged labels.
Changed the title to: "UTF8 characters render differently in the browser than in the console".

@DartBot
Copy link
Author

DartBot commented Feb 13, 2014

This comment was originally written by jcbr...@gmail.com


No, the conversion in OSX Mavericks is render wrong charset. Look in code:


Attachment:
[Captura de Tela 2014-02-13 às 20.18.24.png](https://storage.googleapis.com/google-code-attachments/dart/issue-16800/comment-2/Captura de Tela 2014-02-13 às 20.18.24.png) (290.17 KB)

@DartBot
Copy link
Author

DartBot commented Feb 13, 2014

This comment was originally written by jcbr...@gmail.com


May be this issue happens only in osx. I dont remember this in windows.

@blois
Copy link
Contributor

blois commented Feb 13, 2014

I can't repro this on either OSX or Linux.

This character is a fairly common one (\u00ED;LATIN SMALL LETTER I WITH ACUTE;Ll;0;L), font issue seems surprising, though console output is definitely not held to the same standard as page rendering.

Can also test this via JS in the console:

JSON.parse('[{"nome":"alícia"}]')

or just this should repro:
'al\u00EDcia'

If it does not repro in JS then it's more of a Dart issue and should definitely be tracked down.

@lrhn
Copy link
Member

lrhn commented Feb 14, 2014

This does not sound like a JSON decode problem. The input to JSON.decode is a Dart string, so it is always UTF-16, no matter what how the source code was encoded.

Does the same problem happen if you write the value as a Dart literal:
  var jason1 = [{"Nome": "Alícia"}](i.e., without going through JSON.decode)?

I see no problem when running this on Linux in the stand-alone Dart-VM, or through the Dart Editor. Could be OSX only - my command line shell is unicode aware, so it prints correctly.

The picture shows that the Editor doesn't recognize the source code as UTF-8, but probably thinks it is ISO-Latin-1 or Windows-1252.
The editor is the one serving the file to Dartium when you run it through the editor, so it would make sense if it sent the wrong encoding with the file as well.

Can you try opening the inspector in Dartium (this will break the debug connection to the editor, but that's fine for now), click on the "Network" tab, and then reload the page. Then check the "table.html" file's "headers" tab, under "Response headers", and see what the "Content-Type" entry says?

(Tentatively setting to Area-Editor until we know more)


Removed Library-Html label.
Added Area-Editor, OpSys-OSX, NeedsInfo labels.

@DartBot
Copy link
Author

DartBot commented Feb 14, 2014

This comment was originally written by jcbri...@gmail.com


Content-Type:text/html

@danrubel
Copy link

I tried this on both Mac and Linux, and it appears to work as intended (Mac screenshots attached). Perhaps this is an issue related to the OS language setting?


Attachments:
2014-02-18_16-30-52.png (299.80 KB)
2014-02-18_16-31-27.png (300.18 KB)

@clayberg
Copy link

Removed Area-Editor label.

@DartBot
Copy link
Author

DartBot commented Sep 3, 2014

This comment was originally written by jsing...@gmail.com


This might be related to bug 18150.

No encoding seems to be set when the editor serves the file:

HTTP/1.1 200 OK
content-type: application/dart
date: Wed, 03 Sep 2014 16:39:33 GMT
transfer-encoding: chunked
content-encoding:
server: dart:io with Shelf

@alan-knight
Copy link
Contributor

Set owner to @alan-knight.
Removed Priority-Unassigned label.
Added Priority-Medium label.

@DartBot DartBot added Type-Defect os-osx needs-info We need additional information from the issue author (auto-closed after 14 days if no response) labels Jan 15, 2015
@floitschG
Copy link
Contributor

Closing this issue as duplicate of #18150.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-info We need additional information from the issue author (auto-closed after 14 days if no response) os-osx
Projects
None yet
Development

No branches or pull requests

8 participants