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

Having trouble with UTF-8 special characters #56

Closed
bwl21 opened this issue Nov 26, 2015 · 7 comments
Closed

Having trouble with UTF-8 special characters #56

bwl21 opened this issue Nov 26, 2015 · 7 comments
Assignees
Labels
Milestone

Comments

@bwl21
Copy link
Contributor

bwl21 commented Nov 26, 2015

If the template or my email contains special characters such as öäü ® etc. the HTML string delivered to the backend has wrong encoding. This happens regardless if the template has the special characters or if the email author entered these.

It is hard for me to find out, where the issue comes from:

Wherever it is, If I observe the HTML in a php debugger (intelliJ Idea), the special characters are show as ���

I tried with mosaico.io, but there it works.

Any hint is welcome.

@bago
Copy link
Member

bago commented Nov 26, 2015

The form is here, if you want to try adding the accept-encoding attribute: src\tmpl\main.tmpl.html
Another thing you can do is to use html entities in the template.

My users always create contents in UTF-8 and it works fine, but the encoded chars are not in the template, but in their content (but this is submitted all together by mosaico in the same post, so I guess it is something else)

If you want to deal with UTF-8 the backend must use the mb* string functions and not the usual string functions.

You can use the network tab in your Chrome to see if the content posted by mosaico.io has the same encoding of the content posted to your own website.

@bago bago added the question label Nov 26, 2015
@bwl21
Copy link
Contributor Author

bwl21 commented Nov 26, 2015

I tried with html entities in the template, but got the same result. I want to work in UTF-8 at all.

In chrome network tab, the content posted by mosaico looks not very different than the one from my own website:

my site: it says that the value of html cannot be decoded even if the request header looks the same.

screenshot_402

mosaico.io: the value of html is visible

screenshot_401

@bago
Copy link
Member

bago commented Nov 26, 2015

Make sure you apache is configured to default to utf8 and you php is configured to use utf8.
As you saw, mosaico.js has no issues dealing with UTF8.

@bwl21
Copy link
Contributor Author

bwl21 commented Nov 26, 2015

Chrome says that it cannot decode the value of Html - Field in the request. This made me think, that the issue is not on the server side.

this is from my phpinfo. Could this be the problem?

Local Value Master Value

iconv.input_encoding ISO-8859-1 ISO-8859-1
iconv.internal_encoding ISO-8859-1 ISO-8859-1
iconv.output_encoding ISO-8859-1 ISO-8859-1

@bwl21
Copy link
Contributor Author

bwl21 commented Nov 26, 2015

It appears to me that I need in editor.html:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

or

<meta charset="utf-8" />

more detailes in http://stackoverflow.com/questions/4696499/meta-charset-utf-8-vs-meta-http-equiv-content-type

as InlineStyle uses PHP DOMDocument, i will take the long version for now.

I propose to add this line in mosacio as well.

bwl21 added a commit to bwl21/mosaico-php-backend that referenced this issue Nov 26, 2015
@bago bago added bug and removed question labels Nov 26, 2015
@bago bago added this to the 0.12 milestone Nov 26, 2015
@bago bago self-assigned this Nov 26, 2015
@bago bago closed this as completed in 1cb28d2 Nov 26, 2015
@bago
Copy link
Member

bago commented Nov 26, 2015

So, if I understand it correctly, this is needed when the web server does not default to UTF-8 when publishing contents (As I don't see any change in Node.js and on my "default" Apache Httpd 2.4 deployment.

@bwl21
Copy link
Contributor Author

bwl21 commented Nov 26, 2015

This is how I understand it. I tested it on three different Apache Installations (one of it was a out of the box Bitname mamp stack). I could not even find out what the default setting was. One comment on stackoverflow said, that Apache configuration needs to be set to UTF-8 in order to make the <meta ... change work.

But all the three sytems the change fixed the problem of this issue.

Thanks for changing it in your distribution.

bwl21 added a commit to bwl21/mosaico-php-backend that referenced this issue Nov 27, 2015
* feature/Integrate_Inlinestyle:
  Added <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> see voidlabs/mosaico#56
  Integrate https://github.com/christiaan/InlineStyle Updated readme.md accordingly. Ignore generated files in this repository.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants