This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » support » General discussion » using select_country() in ia0-8859-1 documents
using select_country() in ia0-8859-1 documents [message #7752] Thu, 22 June 2006 13:00 Go to next message
hautzi  is currently offline hautzi
Messages: 21
Registered: April 2006
Location: Heilbronn, Germany
Junior Member

hello,

i'm using the select_country() function to get a list of all countries - but german 'umlaute' like 'äöü' aren't displayed correctly.

i've tried to change the enconding of the .dat file containing the information in <pear-path>/data/symfony/i18n/ but it also didn't work.

is there a solution for that?

greetrings
christoph hautzinger


http://diginights.com
Re: using select_country() in ia0-8859-1 documents [message #7783 is a reply to message #7752 ] Fri, 23 June 2006 09:00 Go to previous messageGo to next message
simonbun  is currently offline simonbun
Messages: 205
Registered: October 2005
Faithful Member
The problem with select_country_tag is that the array of countries get's asort-ed. asort is not multibyte aware, but does have a locale sort flag.

What we could do is have sfUser::setCulture() also set php's internal locale...for example

setlocale(LC_ALL, 'en_US');


and then use

asort($countries, SORT_LOCALE_STRING);


I havent tested any of this, but it should work.


In PHP6 the whole locale thing is reworked however. It will be replaced by i18n_loc_set_default().
Re: using select_country() in ia0-8859-1 documents [message #15912 is a reply to message #7752 ] Tue, 14 November 2006 15:26 Go to previous messageGo to next message
aleckan  is currently offline aleckan
Messages: 43
Registered: March 2006
Location: sweden
Member

I have the same problem, and this fix does not work.

what should I do?


best regards
alexander engvall
http://blog.trans4m.se
Re: using select_country() in ia0-8859-1 documents [message #15915 is a reply to message #7752 ] Tue, 14 November 2006 15:53 Go to previous messageGo to next message
halfer  is currently offline halfer
Messages: 9535
Registered: January 2006
Location: West Midlands, UK
Faithful Member
I am not familiar with the problem, but it looks like select_country_tag could be rewritten to use a multi-byte-aware sort routine.


Remember Palestine
Re: using select_country() in ia0-8859-1 documents [message #15918 is a reply to message #7752 ] Tue, 14 November 2006 16:07 Go to previous messageGo to next message
aleckan  is currently offline aleckan
Messages: 43
Registered: March 2006
Location: sweden
Member

the sorting is not the problem, the problem is that characters like åäö are not dislpayed properly inside the selecttag when using iso8859-1


best regards
alexander engvall
http://blog.trans4m.se
Re: using select_country() in ia0-8859-1 documents [message #15923 is a reply to message #7752 ] Tue, 14 November 2006 17:29 Go to previous messageGo to next message
halfer  is currently offline halfer
Messages: 9535
Registered: January 2006
Location: West Midlands, UK
Faithful Member
Yes, but if I understand simonbun's message correctly, it is asort that is corrupting the special characters.


Remember Palestine
Re: using select_country() in ia0-8859-1 documents [message #15926 is a reply to message #15923 ] Tue, 14 November 2006 17:37 Go to previous messageGo to next message
aleckan  is currently offline aleckan
Messages: 43
Registered: March 2006
Location: sweden
Member

halfer wrote on Tue, 14 November 2006 17:29

Yes, but if I understand simonbun's message correctly, it is asort that is corrupting the special characters.


nope, I have tried to remove the sorting and the result is the same with the corrupt characters

[Updated on: Tue, 14 November 2006 17:38]


best regards
alexander engvall
http://blog.trans4m.se
Re: using select_country() in ia0-8859-1 documents [message #15927 is a reply to message #7752 ] Tue, 14 November 2006 17:45 Go to previous messageGo to next message
halfer  is currently offline halfer
Messages: 9535
Registered: January 2006
Location: West Midlands, UK
Faithful Member
Internationalisation isn't my bag, but have you tried utf-8?


Remember Palestine
Re: using select_country() in ia0-8859-1 documents [message #15930 is a reply to message #15927 ] Tue, 14 November 2006 18:14 Go to previous messageGo to next message
aleckan  is currently offline aleckan
Messages: 43
Registered: March 2006
Location: sweden
Member

halfer wrote on Tue, 14 November 2006 17:45

Internationalisation isn't my bag, but have you tried utf-8?


I have had problems with utf-8 on the rest of the site =(


best regards
alexander engvall
http://blog.trans4m.se
Re: using select_country() in ia0-8859-1 documents [message #15931 is a reply to message #7752 ] Tue, 14 November 2006 18:30 Go to previous messageGo to next message
halfer  is currently offline halfer
Messages: 9535
Registered: January 2006
Location: West Midlands, UK
Faithful Member
Oh dear. How about writing a helper that switches special characters to entity equivalents before putting them into the select tag helper?


Remember Palestine
Re: using select_country() in ia0-8859-1 documents [message #15932 is a reply to message #15931 ] Tue, 14 November 2006 19:03 Go to previous messageGo to next message
aleckan  is currently offline aleckan
Messages: 43
Registered: March 2006
Location: sweden
Member

halfer wrote on Tue, 14 November 2006 18:30

Oh dear. How about writing a helper that switches special characters to entity equivalents before putting them into the select tag helper?


it's just that I don't know where to do it as it is allready corrupted before it is sorted.


best regards
alexander engvall
http://blog.trans4m.se
Re: using select_country() in ia0-8859-1 documents [message #15943 is a reply to message #7752 ] Tue, 14 November 2006 23:20 Go to previous messageGo to next message
halfer  is currently offline halfer
Messages: 9535
Registered: January 2006
Location: West Midlands, UK
Faithful Member
It does it in PEAR/symfony/helper/FormHelper.php. Try this:

<?php
$c 
= new sfCultureInfo(sfContext::getInstance()->getUser()->getCulture());
  
$countries $c->getCountries();
  echo 
"<pre>";
  
print_r($countries);
  echo 
"</pre>";
?>


If that doesn't produce a corrupt array, then the issue would have to be in select_country_tag().


Remember Palestine
Re: using select_country() in ia0-8859-1 documents [message #15946 is a reply to message #15943 ] Wed, 15 November 2006 00:23 Go to previous messageGo to next message
aleckan  is currently offline aleckan
Messages: 43
Registered: March 2006
Location: sweden
Member

that code produces the same error. example:

[AE] => Förenade Arabemiraten


if I use utf-8 the problem is gone, but then I can't have åäö caharcters posted properly in input tags instead which is even worse.

the question is if the characters are read wrong from the file, and if so if I can change the chartype of the dat file? why aren't the special charcters writen as entitys in the dat file from the beginning?

[Updated on: Wed, 15 November 2006 00:24]


best regards
alexander engvall
http://blog.trans4m.se
Re: using select_country() in ia0-8859-1 documents [message #15950 is a reply to message #15946 ] Wed, 15 November 2006 07:10 Go to previous messageGo to next message
chtito  is currently offline chtito
Messages: 512
Registered: March 2006
Location: Sweden
Faithful Member
aleckan: i strongly suggest you to switch to utf-8 and solve the input-tag problem instead. There are zillions of web sites that work perfectly well with utf-8. Switch to utf-8 and never worry about encoding ever again.
Re: using select_country() in ia0-8859-1 documents [message #15953 is a reply to message #15950 ] Wed, 15 November 2006 09:39 Go to previous messageGo to next message
aleckan  is currently offline aleckan
Messages: 43
Registered: March 2006
Location: sweden
Member

chtito wrote on Wed, 15 November 2006 07:10

aleckan: i strongly suggest you to switch to utf-8 and solve the input-tag problem instead. There are zillions of web sites that work perfectly well with utf-8. Switch to utf-8 and never worry about encoding ever again.


The problem is I tried to fix that problem earlier but never found a solution. And I use millions of inputs as I'm building a cms.


best regards
alexander engvall
http://blog.trans4m.se
Re: using select_country() in ia0-8859-1 documents [message #15954 is a reply to message #15953 ] Wed, 15 November 2006 09:49 Go to previous messageGo to next message
chtito  is currently offline chtito
Messages: 512
Registered: March 2006
Location: Sweden
Faithful Member
How come you didn't find a solution? As i said there are loads of web sites using input tags and utf-8 and nobody has problem with that. At least people should be able to help you out. What is your problem with input tags? Did you ask about that in this forum before?
Re: using select_country() in ia0-8859-1 documents [message #15956 is a reply to message #15954 ] Wed, 15 November 2006 10:06 Go to previous message
aleckan  is currently offline aleckan
Messages: 43
Registered: March 2006
Location: sweden
Member

chtito wrote on Wed, 15 November 2006 09:49

How come you didn't find a solution? As i said there are loads of web sites using input tags and utf-8 and nobody has problem with that. At least people should be able to help you out. What is your problem with input tags? Did you ask about that in this forum before?


The problem is sort of the same but reversed, when I use utf-8 the $this->getRequestParameter('name_of_field') is corrupt with strange characters instead of the åäöéü etc that should be there. So I don't even have a chance to replace them with html entitys before I save the posted info in the database.

I don't remember if I asked about this earlier as I found the solution in using iso8859-1 instead, and that have worked perfect untill now with the problems using select_country_tag


best regards
alexander engvall
http://blog.trans4m.se
Previous Topic:How to Refine the Search from the Result Set in Symfony.
Next Topic:Symfony Securitiy Issue - validation bypass method
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software