Hi,
I am looking some function to transform characters from code page Windows 1250 and Latin II (DOS) to ASCII.
I have function with DO CASE... where every characters converted to ASCII code. (chr 001-127)
But it slowing my app.
I saw somewhere function to manipulating with string, to replace characters from one string to other, but I cannot find it.
I have this :
FUNCTION lat_ibm_u(ptext)
LOCAL outriadok:=space(0),pocet:=0,i:=0,znak:=0
pocet:=len(ptext) && zistenie poctu znakov v riadku
for i=1 to pocet
znak:=asc(ptext)
DO CASE
* Š
CASE znak==138
znak:=83
* Ť
CASE znak==141
znak:=84
* Ž
CASE znak==142
znak:=90
etc.
ENDCASE
outriadok+=chr(znak)
next
RETURN outriadok
Transform string fron one code page xxx to ASCII
-
- Posts: 605
- Joined: Thu Jan 28, 2010 9:11 pm
- Location: Steven Point, Wisconsin USA
- Contact:
Re: Transform string fron one code page xxx to ASCII
Instead of a case statement, just create a 1 dimensional array with the conversion. Then your code instead of the case statement would be:
// define array of conversions for the asc return values
aCodes[138] := 83
aCodes[141] := 84
aCodes[142] := 90
for i:= 1 to len(fromcode)
nValue := asc(substr(fromcode,i,1))
tocode := tocode+str(aCodes[nValue])
NEXT
// define array of conversions for the asc return values
aCodes[138] := 83
aCodes[141] := 84
aCodes[142] := 90
for i:= 1 to len(fromcode)
nValue := asc(substr(fromcode,i,1))
tocode := tocode+str(aCodes[nValue])
NEXT
Re: Transform string fron one code page xxx to ASCII
you can use different Font / Codepage in a Xbase+ Application.Victorio wrote:I am looking some function to transform characters from code page Windows 1250 and Latin II (DOS) to ASCII.
it is possible to use different Font / Codepage in each Column of a Browse.
greetings by OHR
Jimmy
Jimmy
Re: Transform string fron one code page xxx to ASCII
thanks,
Jimmy , I want convert characters with codes 128 - 255 to base ascii codes 001 - 127
for remove national character.
for example :
Jakešovi -> Jakesovi
and then Jakesovi -> JAKESOVI with upper()
It is because I am searching in document and program must find all variants if I want search key "JAKESOVI"
(Jakešovi, JAKEŠOVI,Jakesovi, Jakesovi,Jakéšoví,....)
Jimmy , I want convert characters with codes 128 - 255 to base ascii codes 001 - 127
for remove national character.
for example :
Jakešovi -> Jakesovi
and then Jakesovi -> JAKESOVI with upper()
It is because I am searching in document and program must find all variants if I want search key "JAKESOVI"
(Jakešovi, JAKEŠOVI,Jakesovi, Jakesovi,Jakéšoví,....)
Re: Transform string fron one code page xxx to ASCII
Code: Select all
FUNCTION Convert(c)
LOCAL aCodeTab := {{138,83},{141,84},{142,90}}, i
FOR i := 1 TO Len(aCodeTab)
c := StrTran(c,Chr(aCodeTab[i,1]),Chr(aCodeTab[i,2]))
NEXT
RETURN c
Code: Select all
FOR i := 1 TO Len(c)
c[i] := Something(c[i])
NEXT
Best regards,
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Re: Transform string fron one code page xxx to ASCII
Hi,
Did you check the following? SET LEXICAL ON with the setlexRule()? I think this is a solution for this kind of problem.
Did you check the following? SET LEXICAL ON with the setlexRule()? I think this is a solution for this kind of problem.
Re: Transform string fron one code page xxx to ASCII
skiman: yes, this is, what I am searching, (setwildcollation). I saw it, but cannot find again..
Thanks !
And also Jimmy, Cliff and others for inspiration to improve my source.
Victorio
Thanks !
And also Jimmy, Cliff and others for inspiration to improve my source.
Victorio