do u know of a way to replace diacritics by simple character (ie. : é
-o-> e)
the same with ligatures (ie. : Æ -o-> AE )
using tables ?
do u know of a way to replace diacritics by simple character (ie. : é
-o-> e)
the same with ligatures (ie. : Æ -o-> AE )
using tables ?
Le 25 septembre à 18:25, Une Bévue a écrit :
(Hello again… )
do u know of a way to replace diacritics by simple character (ie. : é
-o-> e)the same with ligatures (ie. : Æ -o-> AE )
using tables ?
IConv can do that for you :
require “iconv”
=> truei = Iconv.new(“ASCII//TRANSLIT”, “ISO-8859-15”)
=> #Iconv:0x84d4448i.iconv(“aéouï Æ”)
=> “a’eou"i AE”i.iconv(“aéouï Æ”).gsub(/[^a-zA-Z0-9 ]/, ‘’)
=> “aeoui AE”
Fred
–
I’ve found an axe can do a lot for a paper-mangling printer. Especially
if you shout for one at the top of your voice, and then a cow orker
--------------------------------------------------------------------------------------^
???
brings you said instrument. Suddenly, no more paper jams.
(Kai Henningsen in the SDM)
F. Senault [email protected] wrote:
IConv can do that for you :
require “iconv”
=> true
i = Iconv.new(“ASCII//TRANSLIT”, “ISO-8859-15”)
=> #Iconv:0x84d4448
i.iconv(“aéouï Æ”)
=> “a’eou"i AE”
i.iconv(“aéouï Æ”).gsub(/[^a-zA-Z0-9 ]/, ‘’)
=> “aeoui AE”
Fine thanks a lot Fred à c’t’heure
Have a good wine celler
ça marche même avec de l’UTF-8
works also with UTF-8
Le 25 septembre à 20:12, Michal S. a écrit :
–
I’ve found an axe can do a lot for a paper-mangling printer. Especially
if you shout for one at the top of your voice, and then a cow orker
--------------------------------------------------------------------------------------^
???
It’s intentional. Cow orker was probably a typo in the olden times, but
has entered the mainstream since then. Just ask google : “Results 1 -
10 of about 37,200 for “cow orker”. (0.19 seconds)”
Fred
On Sep 25, 2007, at 18:55, F. Senault wrote:
do u know of a way to replace diacritics by simple character (ie. : é
-o-> e)the same with ligatures (ie. : Æ -o-> AE )
using tables ?
IConv can do that for you :
An alternative approach is something like Sean M. Burke’s
Text::Unidecode:
http://interglacial.com/~sburke/tpj/as_html/tpj22.html
Here is an example of an implementation of Unidecode in Lua [1]:
local Unidecode = require( ‘Unidecode’ )
print( Unidecode( ‘МоÑква̒ ) )
print( Unidecode( ‘北京’ ) )
print( Unidecode( ‘Ἀθηνᾶ’ ) )
print( Unidecode( ‘서울’ ) )
print( Unidecode( ‘æ±äº¬’ ) )
print( Unidecode( ‘京都市’ ) )
print( Unidecode( ‘नेपाल’ ) )
print( Unidecode( ‘תֵּל־×ָבִיב-יָפוֹ’ ) )
print( Unidecode( ‘تَلْ أَبÙيبْ يَاÙَا’ ) )
print( Unidecode( ‘تهران’ ) )
print( Unidecode( ‘Géometrie Différentielle’ ) )
Moskva
beijing
Athena
seoul
dongjing
jingdushi
nepaal
te’labiyb-yapvo
tal 'abiyb yaafaa
thran
Geometrie Differentielle
Cheers,
PA.
F. Senault wrote:
IConv can do that for you :
require “iconv”
=> truei = Iconv.new(“ASCII//TRANSLIT”, “ISO-8859-15”)
=> #Iconv:0x84d4448i.iconv(“aéouï Æ”)
=> “a’eou"i AE”i.iconv(“aéouï Æ”).gsub(/[^a-zA-Z0-9 ]/, ‘’)
=> “aeoui AE”
That doesn’t work on all platforms. For me:
require “iconv”
=> truei = Iconv.new(“ASCII//TRANSLIT”, “UTF-8”)
=> #Iconv:0xb7cf28e0i.iconv(“aéouï Æ”)
=> “a?ou? AE”
How do i get off this mailing list ? THANKS!!!
Daniel DeLorme [email protected] wrote:
Are u sure about the encoding of “aéouï Æ” ?
because i did it with UTF-8, it works :
– the script ----------------------------------------------------------
#! /usr/bin/env ruby
require “iconv”
i = Iconv.new(“ASCII//TRANSLIT”, “UTF-8”)
p i.iconv(“aéouï Æ”)
p i.iconv(“aéouï Æ”).gsub(/[^a-zA-Z0-9 ]/, ‘’)
p i.iconv(“Être ou ne pas être, c’est la question. aéouï Æ, wie heiß du
?”).gsub(/[^a-zA-Z0-9’ ]/, ‘’).gsub(/[’ ]/, '').gsub(/(.*)$/, ‘\1’)
p i.iconv(“Être ou ne pas être, c’est la question. aéouï Æ, wie heiß
du?”).gsub(/[^a-zA-Z0-9’ ]/, ‘’).gsub(/[’ ]/, '').gsub(/(.*)$/, ‘\1’)
Une Bévue wrote:
Are u sure about the encoding of “aéouï Æ” ?
yep.
str = “aéouï Æ”
=> “a\303\251ou\303\257 \303\206” #(that’s utf8 allright)i.iconv(str)
=> “a?ou? AE”
but like I said, translit doesn’t work the same on all platforms (I’m on
ubuntu btw)
Daniel
Daniel DeLorme [email protected] wrote:
but like I said, translit doesn’t work the same on all platforms (I’m on
ubuntu btw)
i’m running Mac OS X 10.4.10…
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs