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

nbsp resulting in weird character #16

Open
masugadesign opened this issue Jul 21, 2016 · 12 comments
Open

nbsp resulting in weird character #16

masugadesign opened this issue Jul 21, 2016 · 12 comments

Comments

@masugadesign
Copy link

Hacksaw 1.1.2
Craft 2.6+

Our rich text field has   all over. If we output the field normally, it appears fine.

{{ blogEntry.body }}

But when we use Hacksaw,

{{ blogEntry.body|hacksaw(words='100',allow='<p><b>',append='...') }}

the result is that all the non-breaking spaces are displaying as those odd black diamond characters: �

Any idea why that might be?

@gregorterrill
Copy link

gregorterrill commented Jul 28, 2016

I'm experiencing the same thing both in my Twig templates, and when running something through the HacksawFilter function outside of Twig (in an ElementAPI transformer). Oddly enough, in that case even if I string replace the &nbsp; with spaces, I can confirm that the replace has occurred, but when I pass the modified string to Hacksaw, it still somehow comes back with � where the &nbsp; was originally.

@FrancisBou
Copy link

I have this problem as well with some characters with accents such as "à", but strangely not "û".

@FrancisBou
Copy link

FrancisBou commented Aug 5, 2016

With mbstrings enabled you can fix this:

Replace line 69:
/craft/plugins/hacksaw/twigextensions/HacksawTwigExtension.php
$words = preg_split('/\s+/', $content);
with
$words = mb_split(' ', $content);

@mikestecker
Copy link

Having the same issue. Thanks @FrancisBou for the quick fix.

@joepagan
Copy link

joepagan commented Sep 6, 2016

Having the same issue, you would have though a replace filter after hacksaw would be able to sort this, but, nope!

@dennisfrank
Copy link

Same issue here. #16 (comment) works for me. Hope it can be fixed officially. Thanks for the plugin!

@joepagan
Copy link

@dennisfrank it's fixed, I think, repo has moved here:
https://github.com/ryanshrum/hacksaw

@dennisfrank
Copy link

@lexbi Cool! Thanks.

@masugadesign
Copy link
Author

How are we supposed to know the hacksaw repo moved to a new location and has been updated to 2.0? How did you find that out? I don't see a note of the README here or anything. @lexbi

@joepagan
Copy link

I will let @ryanshrum tell you, not my place.

@masugadesign
Copy link
Author

Sure, I was just curious how you became aware of the new repo. We had no idea it existed.

@joepagan
Copy link

I saw Ryan post in Craft Slack I think. Either that or some of us were discussing it and he chimed in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants