#124636 - 2004-08-09 06:53 AM
Replace German Umlaute
|
Rainer_Piechura
Fresh Scripter
Registered: 2004-08-09
Posts: 5
Loc: Bremerhaven, Germany
|
Hi there, using Kix Ver.4.22 on Windows XP I'm having problems to get German Umlaute replaced. I'm using the following Code: [code] SELECT CASE INSTR($NAME,"ä") $NAME = replace($NAME, "ä", "ae") CASE INSTR($NAME,"ö") $NAME = replace($NAME, "ö", "oe") CASE INSTR($NAME,"ü") $NAME = replace($NAME, "ü", "ue") CASE INSTR($NAME,"Ä") $NAME = replace($NAME, "Ä", "Ae") CASE INSTR($NAME,"Ö") $NAME = replace($NAME, "Ö", "Oe") CASE INSTR($NAME,"Ü") $NAME = replace($NAME, "Ü", "Ue") CASE INSTR($NAME,"ß") $NAME = replace($NAME, "ß", "ss") CASE INSTR($NAME," ") $NAME = replace($NAME, " ", "_") ENDSELECT
? $NAME
Function Replace($String,$SS,$RS) $Replace=Join(Split($String,$SS),$RS) EndFunction [/code] If I now translate "Wäsche" it replaces correctly, however having for example "Wäsche Änderung" I get back "Waesche aenderung" Any ideas ?
Thanks, Rainer
|
|
Top
|
|
|
|
#124637 - 2004-08-09 08:27 AM
Re: Replace German Umlaute
|
Jochen
KiX Supporter
   
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
[edit: somehow missed the topic ]
Ok, you need to tell your script to be Case Sensitive
Furthermore you will need the Loop in case of mixed Cases:
Code:
$_ = SETOPTION("CaseSensitivity","ON")
while INSTR($NAME,"ä") or INSTR($NAME,"ö") or INSTR($NAME,"ü")
or INSTR($NAME,"Ä") or INSTR($NAME,"Ö") or INSTR($NAME,"Ü")
or INSTR($NAME,"ß") or INSTR($NAME," ")
SELECT
CASE INSTR($NAME,"ä")
$NAME = replace($NAME, "ä", "ae")
CASE INSTR($NAME,"ö")
$NAME = replace($NAME, "ö", "oe")
CASE INSTR($NAME,"ü")
$NAME = replace($NAME, "ü", "ue")
CASE INSTR($NAME,"Ä")
$NAME = replace($NAME, "Ä", "Ae")
CASE INSTR($NAME,"Ö")
$NAME = replace($NAME, "Ö", "Oe")
CASE INSTR($NAME,"Ü")
$NAME = replace($NAME, "Ü", "Ue")
CASE INSTR($NAME,"ß")
$NAME = replace($NAME, "ß", "ss")
CASE INSTR($NAME," ")
$NAME = replace($NAME, " ", "_")
ENDSELECT
loop
? $NAME
Edited by Jochen (2004-08-09 08:46 AM)
_________________________
|
|
Top
|
|
|
|
#124639 - 2004-08-09 09:14 AM
Re: Replace German Umlaute
|
Rainer_Piechura
Fresh Scripter
Registered: 2004-08-09
Posts: 5
Loc: Bremerhaven, Germany
|
Hi Jochen, thanx for your help. I tried $NAME = "Ändern,Wäsche,Überraschung,überwintern" and it still comes up with "aendern,Waesche,ueberraschung,ueberwintern"
Any other ideas ?
Rainer
P.S. Changed the location, thanx......
|
|
Top
|
|
|
|
#124641 - 2004-08-09 09:34 AM
Re: Replace German Umlaute
|
Rainer_Piechura
Fresh Scripter
Registered: 2004-08-09
Posts: 5
Loc: Bremerhaven, Germany
|
Hi Jochen, KiXtart 2001 4.22
Here ist the complete code again: Code:
$_ = SETOPTION("CaseSensitivity","ON")
$NAME = "Ändern,Wäsche,Überraschung,überwintern"
while INSTR($NAME,"ä") or INSTR($NAME,"ö") or INSTR($NAME,"ü") or INSTR($NAME,"Ä") or INSTR($NAME,"Ö") or INSTR($NAME,"Ü") or INSTR($NAME,"ß") or INSTR($NAME," ") SELECT CASE INSTR($NAME,"ä") $NAME = replace($NAME, "ä", "ae") CASE INSTR($NAME,"ö") $NAME = replace($NAME, "ö", "oe") CASE INSTR($NAME,"ü") $NAME = replace($NAME, "ü", "ue") CASE INSTR($NAME,"Ä") $NAME = replace($NAME, "Ä", "Ae") CASE INSTR($NAME,"Ö") $NAME = replace($NAME, "Ö", "Oe") CASE INSTR($NAME,"Ü") $NAME = replace($NAME, "Ü", "Ue") CASE INSTR($NAME,"ß") $NAME = replace($NAME, "ß", "ss") CASE INSTR($NAME," ") $NAME = replace($NAME, " ", "_") ENDSELECT loop
? $NAME
Function Replace($String,$SS,$RS) $Replace=Join(Split($String,$SS),$RS) EndFunction
|
|
Top
|
|
|
|
#124642 - 2004-08-09 09:52 AM
Re: Replace German Umlaute
|
Jochen
KiX Supporter
   
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
|
|
Top
|
|
|
|
#124643 - 2004-08-09 12:04 PM
Re: Replace German Umlaute
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Looks like Split() is not case sensitive - I just checked with 4.21 and 4.50.
This version using a different Replace seems to work ok, and you don't need to switch case sensitivity on: Code:
$NAME = "Ändern,Wäsche,Überraschung,überwintern" $NAME = replace($NAME, "Ä", "Ae") $NAME = replace($NAME, "Ö", "Oe") $NAME = replace($NAME, "Ü", "Ue") $NAME = replace($NAME, "ß", "ss") $NAME = replace($NAME, "ä", "ae") $NAME = replace($NAME, "ö", "oe") $NAME = replace($NAME, "ü", "ue") $NAME = replace($NAME, " ", "_") ? $NAME Function Replace($String,$SS,$RS) While $String If Left($String,1)==$SS $Replace=CStr($Replace)+$RS Else $Replace=CStr($Replace)+Left($String,1) EndIf $String=SubStr($String,2) Loop EndFunction
|
|
Top
|
|
|
|
#124644 - 2004-08-09 12:15 PM
Re: Replace German Umlaute
|
Jochen
KiX Supporter
   
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
Quote:
Looks like Split() is not case sensitive
Huh ?
I run this :
Code:
break on
$_ = SETOPTION("CaseSensitivity","ON")
$NAME = "Ändern,Wäsche,Überraschung,überwintern"
while INSTR($NAME,"ä") or INSTR($NAME,"ö") or INSTR($NAME,"ü")
or INSTR($NAME,"Ä") or INSTR($NAME,"Ö") or INSTR($NAME,"Ü")
or INSTR($NAME,"ß") or INSTR($NAME," ")
SELECT
CASE INSTR($NAME,"ä")
$NAME = replace($NAME, "ä", "ae")
CASE INSTR($NAME,"ö")
$NAME = replace($NAME, "ö", "oe")
CASE INSTR($NAME,"ü")
$NAME = replace($NAME, "ü", "ue")
CASE INSTR($NAME,"Ä")
$NAME = replace($NAME, "Ä", "Ae")
CASE INSTR($NAME,"Ö")
$NAME = replace($NAME, "Ö", "Oe")
CASE INSTR($NAME,"Ü")
$NAME = replace($NAME, "Ü", "Ue")
CASE INSTR($NAME,"ß")
$NAME = replace($NAME, "ß", "ss")
CASE INSTR($NAME," ")
$NAME = replace($NAME, " ", "_")
ENDSELECT
loop
? $NAME
get $
exit 1
Function Replace($String,$SS,$RS)
$Replace=Join(Split($String,$SS),$RS)
EndFunction
and what it returns is this :
Code:
Aendern,Waesche,Ueberraschung,ueberwintern
So it must be Case Sensitive, no?
Edited by Jochen (2004-08-09 12:17 PM)
_________________________
|
|
Top
|
|
|
|
#124645 - 2004-08-09 01:13 PM
Re: Replace German Umlaute
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Just tried again with 4.21 and 4.50 (I don't have 4.22 to hand)
This simple test: Code:
$=SetOption("CaseSensitivity","ON") ? @KIX ? $NAME = "Ändern Wäsche" "Test string is: " $NAME ? "Using Split/Join: " Replace_type1($NAME, "Ä", "Ae") ? "Using character test: " Replace_type2($NAME, "Ä", "Ae") ? Function Replace_type1($s,$t,$r) $Replace_type1=Join(Split($s,$t),$r) EndFunction Function Replace_type2($String,$SS,$RS) While $String If Left($String,1)==$SS $Replace_type2=CStr($Replace_type2)+$RS Else $Replace_type2=CStr($Replace_type2)+Left($String,1) EndIf $String=SubStr($String,2) Loop EndFunction
I get: Code:
[KiXtart 4.21] 4.21 Test string is: Ändern Wäsche Using Split/Join: Aendern WAesche Using character test: Aendern Wäsche [KiXtart 4.50] 4.50 Alpha TEST Release Test string is: Ändern Wäsche Using Split/Join: Aendern WAesche Using character test: Aendern Wäsche
|
|
Top
|
|
|
|
#124647 - 2004-08-10 06:18 AM
Re: Replace German Umlaute
|
Rainer_Piechura
Fresh Scripter
Registered: 2004-08-09
Posts: 5
Loc: Bremerhaven, Germany
|
Hi there, when I'm using the replace function from Richard it works great. Maybe it also depends on the OS ??  Anyhow thanks for your help.
Rainer
|
|
Top
|
|
|
|
#124648 - 2004-08-10 08:24 AM
Re: Replace German Umlaute
|
Jochen
KiX Supporter
   
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
|
|
Top
|
|
|
|
#124649 - 2004-08-10 11:08 AM
Re: Replace German Umlaute
|
Rainer_Piechura
Fresh Scripter
Registered: 2004-08-09
Posts: 5
Loc: Bremerhaven, Germany
|
Agree,
the Code from Richard works, let's see what 4.50 will do to that Code 
Thanx again............
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Henriques)
and 2516 anonymous users online.
|
|
|