Sorry Martin
But I posted it in the wrong group and it has been moved to rails-se
For your information

One problem was that I use request.raw_post to get the search string and that does no handle ÖÅÄ öäå My mistake. Did not really understad how autocomplete worked when I forst wrote that code The proposed solution was to use params['search'] instad that should take care of that

The second problem was about how to search only för ÖÄÅ in an autocomplete field
and the proposed solution was to use
['name COLLATE utf8_swedish_ci LIKE ?', '%' + search + '%' ]
as search condition

____________________________________________
Hans Marmolin
St: Larsgatan 50, 58224 Linköping, Sweden
Phone: +46708371202









14 feb 2011 kl. 02.14 skrev Martin J. Dürst:

Hello Hans,

Can you please post question and answer (or a summary thereof) in English, so that the rest of the subscribers can follow the discussion?

[From looking at the code, a function such as *to_utf8* below is extremely restricted, and there is a high chance that you soon get hit with a character that's not in your list.]

Regards,    Martin.

On 2011/02/13 19:18, Hans Marmolin wrote:
Hej
Jag har en rails applikation som använder MYSQL och har definierat
tabellerna enligt
create_table :places, :force => true, :force => true, :options =>
'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |table|

och html filen enligt
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=8" />

och databsen i configurationsflen enligt
development:
adapter: mysql
encoding: utf8
database: Disweb_1-development
username: root
password:
host: localhost
pool: 5
timeout: 5000


Mina problem är
1. När jag använder autocomplete och gör
search=request.raw_post.downcase.split('=').second.split('&').first
för att ta ut söksträngen så får jag '%c3%b6' liknande tecken för ÅÄÖ
Detta åtgärdar jag med följande fix

def to_uf8(search)
#- fix to handle utf8 problem when inputting search chrs
search.gsub!('%c3%b6','ö')
search.gsub!('%c3%a4','ä')
search.gsub!('%c3%a5','å')
search.gsub!('%c3%96','Ö')
search.gsub!('%c3%84','Ä')
search.gsub!('%c3%85','Å')
return search
end

Vilket inte verkar vara rätt väg att gå !!!

2. När jag söker efter matchningar enligt
['LOWER(name) LIKE ?', '%' + search.downcase + '%' ]
ger search med AÅÄ samma resultat, dvs Å i autocompletefältet matchar
alla namn som har ÅÄA

3. Nu vet jag inte om det finns samma problem alla gånger jag använder
find med ÅÄÖ i villkorssatsen ?
I så fall är jag illa ute !

Jag har läst att man ev kan åtgärda detta med att collation=utf8_unicode_c
men var och hur definierar man detta ?

Finns det andra lösningar till mina problem ?

Tacksam för all hjälp !

____________________________________________
Hans Marmolin
St: Larsgatan 50, 58224 Linköping, Sweden
Phone: +46708371202










--
#-# Martin J. Dürst, Professor, Aoyama Gakuin University
#-# http://www.sw.it.aoyama.ac.jp   mailto:[email protected]

--
You received this message because you are subscribed to the Google Groups "rails-i18n" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected] . For more options, visit this group at http://groups.google.com/group/rails-i18n?hl=en .



--
You received this message because you are subscribed to the Google Groups 
"rails-i18n" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rails-i18n?hl=en.

Reply via email to