Welcome Guest, Not a member yet? Register   Sign In
CI2 - convert_accented_characters() gives bad codes
#1

[eluser]Phil Sturgeon[/eluser]
Using the new convert_accented_characters() function in text_helper.php I am getting failed conversions of characters.

The following characters should be supported:

Code:
'232'    =>    "e",  // è
                            '233'    =>    "e",  // é
                            '234'    =>    "e",  // ê                                  
                            '235'    =>    "e",  // ë

The numbers on the left are the character codes. However when I try this:

Code:
echo convert_accented_characters('ë');

I get � returned here, so I have put a debug step into the function here:

Code:
return $ord = ord($match['1']);

The codes I get for these four characters are:

Quote:è - 168
é - 169
ê - 170
ë - 171

These numbers are not in the config file at all, as it only starts from 223.

I am using Mac OSX, PHP 5.2.11. Charset is UTF-8 and the browser is FF 3.6.

Not sure if I should simply add these missing characters into the config file or what?


Anybody else getting this? I have submitted it to the bug tracker too.

P.S ü - 188 >.<
#2

[eluser]Jamie Rumbelow[/eluser]
Yo Phil,

If you haven't already (just checked, you haven't), please chuck this in the issue tracker on BitBucket; the EllisLab team are looking to see how much feedback they can get through that and see if it's the better way of dealing with it.

Cheers,

J
#3

[eluser]Phil Sturgeon[/eluser]
Didn't even think of that. I've been putting everything in the bug tracker. I'm without Internet for the weekend again so I'll just put new bugs in them from Monday. Could you raise them as issues on my behalf?
#4

[eluser]Jamie Rumbelow[/eluser]
'Course I can mate, it's on the list of things to do. Hah, this is turning into an public email.

J
#5

[eluser]bob.rosset[/eluser]
Hey mates, I know this is old but I just wanna ask a quick question.

I'm working on a French and Spanish site nowadays, and for some reason, on my local environment, è is being converted into e, but on the server, è ends up being ?.
I found that if I use a real è instead of $egrave; everything is fine. But sometimes I use &egrave; (or some other entities) and that throws me an error.

If you can point me to the right place, I can adapt the php file to allow and convert those characters.

So the question is, will it help to create a fix for that exception?

Cheers!
#6

[eluser]TheFuzzy0ne[/eluser]
You need to make sure that the page has the correct encoding, and that your database field also has the correct encoding. I also suspect that $egrave; (a PHP variable) should actually be &amp;egrave; (an HTML entity).
#7

[eluser]bob.rosset[/eluser]
TheFuzzy0ne, $egrave; is an HTML entity code, not a php variable.
But what I wanna do is submit a fix for some other folks that might face the same issue.

The encoding is UTF-8. But I'm working on a mac (MAMP). And the server is a Linux (LAMP). That's the major difference and why it's working on my local and not on the server. The quick solution is to avoid those codes and use the è character directly, or the entity number instead of the name (Entity number: è vs Entity name: &egraveWink, however, some wysiwyg might use &egrave; and adding the ability to parse those characters also is a really almost-no-effort task that can save up a lot of time.

Again, I'm not posting a problem, but a possible solution that the team can include on an update.

Cheers mate,
#8

[eluser]TheFuzzy0ne[/eluser]
Sorry, I must've misread your post.

I use [url="http://www.vagrantup.com/"]Vagrant[/url] and [url="https://puppetlabs.com/"]Puppet[/url] to provision new VMs that I can use for Web development. It allows you to mimic your production server, or at the very least, run the same OS as your production server, which helps to combat the "well it works on this machine, but not that machine" scenario.




Theme © iAndrew 2016 - Forum software by © MyBB