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

Some characters are changed after render. #94

Open
satalways opened this issue Jul 21, 2015 · 9 comments
Open

Some characters are changed after render. #94

satalways opened this issue Jul 21, 2015 · 9 comments
Labels

Comments

@satalways
Copy link

Hi,
I am facing problem about characters ...

.glyphicon-shopping-cart:before{content:"\e116"}

are converted into

.glyphicon-shopping-cart:before {content: "î„–";}

@sabberworm
Copy link
Contributor

This is a bug.

Currently, all string escapes are parsed and represented in the charset specified. Since you probably did not specify a charset either in the parser settings or the source CSS (via @charset), utf-8 is used. On the bright side, this means the character can be fully represented but it also means the file must be opened/served in utf-8.

The fix would be as follows:

  • Sabberworm\CSS\Value\String values should always be parsed internally as unicode and not converted to the source encoding (only from the source encoding).
  • There should be a formatter option to decide which encoding to use for outputting.
  • There should be a formatter option to decide when to output unicode escapes (always, only_when_necessary (if the destination charset can’t handle the character), all_beyond_bmp, all_beyond_ascii).

@sabberworm sabberworm added the tbd label Jul 22, 2015
@satalways
Copy link
Author

Can you please provide snippet/sample ... Thanks.

@sabberworm
Copy link
Contributor

A snippet for what?

@satalways
Copy link
Author

Snippet for changing character set or you will fix it in future.. ?

@sabberworm
Copy link
Contributor

Put,@charset latin1 or whichever your character set is at the top of the file. But as I said it's a bug which I have to fix because if \e116 is not representable in said character set, just setting it won't work.

@sabberworm
Copy link
Contributor

The only fix that will certainly work is using some utf-encoding all the way.

@neel-pu
Copy link

neel-pu commented Apr 14, 2016

I'm having this same problem. How do I set the utf-8 encoding?

@skodak
Copy link

skodak commented Aug 21, 2016

I guess this should be resolved by #116

@EMDM45
Copy link

EMDM45 commented Nov 17, 2018

I use FontAwesome and i have the same problem! What can i do to fix it ?

$oCssParser = new Sabberworm\CSS\Parser('.a:after{content:"\f2da"}');
$oCssDocument = $oCssParser->parse();
echo $oCssDocument;

Result:

PHP notice: iconv(): Wrong charset, conversion from `utf-32le' to `utf-8' is not allowed
.a:after {content: "";}

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

5 participants