Discussion:
oem to ansi function for clipper
(too old to reply)
Andreas Moroder
2008-12-31 09:29:42 UTC
Permalink
Hello,

I have to convert clipper strings with german and italian special
characters to a ANSI string. Does a function similar to the windows
OEMTOANSI( ) exist for clipper ?

Happy New Year
Andreas
N:dlzc D:aol T:com (dlzc)
2008-12-31 13:06:44 UTC
Permalink
Dear Andreas Moroder:

"Andreas Moroder" <Andreas.moroder@[nospam]sb-brixen.it> wrote in
message news:gjfh2j$gt3$***@news.dtag.de...
...
Post by Andreas Moroder
I have to convert clipper strings with german and
italian special characters to a ANSI string. Does
a function similar to the windows OEMTOANSI( ) exist for
clipper ?
strtran() is the only one I know of. One invocation per letter
to be substituted.

David A. Smith
Antonio Martinez
2008-12-31 14:00:06 UTC
Permalink
Andreas,

A ver si te vale esto:

*
//--------------------------------------------------------------------------
//
// Mi oemtoansi para programas DOS
FUNCTION DOSOemToAnsi(cOem)
#Define CAD_OEM ;
"€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ
¡¢£€¥Š§š©ª«¬­®¯°±²³Žµ¶·ž¹º»ŒœŸ¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëì
íîïðñòóôõö÷øùúûüýþÿ"
#Define ARR_ASC_ANSI ;
{164,182,167,199,252,233,226,228,224,229,231,234,235,232,239,238,236,196,197
,201,230,198,244,246,242,251,249,255,214,220,248,163,216,215,131,225,237,243
,250,241,209,170,186,191,174,172,189,188,161,171,187,166,166,166,166,166,193
,194,192,169,166,166,43,43,162,165,43,43,45,45,43,45,43,227,195,43,43,45,45,
166,45,43,164,240,208,202,203,200,105,205,206,207,43,43,166,95,166,204,175,2
11,223,212,210,245,213,181,254,222,218,219,217,253,221,175,180,173,177,61,19
0,182,167,247,184,176,168,183,185,179,178,166,160}
*
Local nI, nLen:= Len(cOem), nPos
Local cCad:= CAD_OEM, aCad:= ARR_ASC_ANSI
Local cAnsi:= "", cCar
FOR nI:= 1 TO nLen
cCar:= SubStr(cOem, nI, 1)
nPos:= At(cCar, cCad)
IF nPos> 0
cCar:= Chr(aCad[nPos])
ENDIF
cAnsi+= cCar
NEXT
RETURN cAnsi
//--------------------------------------------------------------------------
//
// Mi ANSITOOEM para programas DOS
FUNCTION DOSAnsiToOem(cAnsi)
*
Local nI, nLen:= Len(cAnsi), nPos
Local cCad:= CAD_OEM, aCad:= ARR_ASC_ANSI
Local coem:= "", cCar
FOR nI:= 1 TO nLen
cCar:= SubStr(cAnsi, nI, 1)
nPos:= aPosition(Asc(cCar), aCad)
IF nPos> 0
cCar:= SubStr(cCad, nPos, 1)
ENDIF
coem+= cCar
NEXT
RETURN cOem
*
*
*





Saludos


N:dlzc D:aol T:com (dlzc) escribió en mensaje ...
Post by N:dlzc D:aol T:com (dlzc)
...
Post by Andreas Moroder
I have to convert clipper strings with german and
italian special characters to a ANSI string. Does
a function similar to the windows OEMTOANSI( ) exist for
clipper ?
strtran() is the only one I know of. One invocation per letter
to be substituted.
David A. Smith
Claudio Voskian
2008-12-31 14:28:19 UTC
Permalink
Antonio

[english]
I guess that if you can change the definition of CAD_OEM to not be literal
string of chars, and put them as literal ascii codes, then we can see what
is the proposed translation.
As you can see, posting in a newsgroup make changes to certain text,
specially the chars not mapped to a given font.
Regards,

[espaniol]
Imagino que si cambias la definicion de CAD_OEM de texto literal como
secuencia de caracteres, a la definicion de su valor en ascii, podremos
interpretar cual es la traduccion que propones.
Al publicar un mensaje en un sitio de noticias, algo del texto que no tiene
mapeo directo segun el font de caracteres, se pierden y es imposible de
interpretar.
Saludos!
--
Lic. Claudio Voskian
ICQ#: 18122595 - Aol/Msn/Skype/Y!: cvoskian
Buenos Aires - Argentina
Post by Antonio Martinez
Andreas,
*
//--------------------------------------------------------------------------
//
// Mi oemtoansi para programas DOS
FUNCTION DOSOemToAnsi(cOem)
#Define CAD_OEM ;
"?,f".??^?SozY
¡¢£€¥Š§š©ª«¬­®¯°±²³Žµ¶·ž¹º»ŒœŸ¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëì
íîïðñòóôõö÷øùúûüýþÿ"
#Define ARR_ASC_ANSI ;
{164,182,167,199,252,233,226,228,224,229,231,234,235,232,239,238,236,196,197
,201,230,198,244,246,242,251,249,255,214,220,248,163,216,215,131,225,237,243
,250,241,209,170,186,191,174,172,189,188,161,171,187,166,166,166,166,166,193
,194,192,169,166,166,43,43,162,165,43,43,45,45,43,45,43,227,195,43,43,45,45,
166,45,43,164,240,208,202,203,200,105,205,206,207,43,43,166,95,166,204,175,2
11,223,212,210,245,213,181,254,222,218,219,217,253,221,175,180,173,177,61,19
0,182,167,247,184,176,168,183,185,179,178,166,160}
*
Local nI, nLen:= Len(cOem), nPos
Local cCad:= CAD_OEM, aCad:= ARR_ASC_ANSI
Local cAnsi:= "", cCar
FOR nI:= 1 TO nLen
cCar:= SubStr(cOem, nI, 1)
nPos:= At(cCar, cCad)
IF nPos> 0
cCar:= Chr(aCad[nPos])
ENDIF
cAnsi+= cCar
NEXT
RETURN cAnsi
//--------------------------------------------------------------------------
//
// Mi ANSITOOEM para programas DOS
FUNCTION DOSAnsiToOem(cAnsi)
*
Local nI, nLen:= Len(cAnsi), nPos
Local cCad:= CAD_OEM, aCad:= ARR_ASC_ANSI
Local coem:= "", cCar
FOR nI:= 1 TO nLen
cCar:= SubStr(cAnsi, nI, 1)
nPos:= aPosition(Asc(cCar), aCad)
IF nPos> 0
cCar:= SubStr(cCad, nPos, 1)
ENDIF
coem+= cCar
NEXT
RETURN cOem
*
*
*
Saludos
N:dlzc D:aol T:com (dlzc) escribió en mensaje ...
Post by N:dlzc D:aol T:com (dlzc)
...
Post by Andreas Moroder
I have to convert clipper strings with german and
italian special characters to a ANSI string. Does
a function similar to the windows OEMTOANSI( ) exist for
clipper ?
strtran() is the only one I know of. One invocation per letter
to be substituted.
David A. Smith
Antonio Martinez
2009-01-02 08:51:34 UTC
Permalink
Claudio,
Post by Claudio Voskian
Imagino que si cambias la definicion de CAD_OEM de texto literal como
secuencia de caracteres, a la definicion de su valor en ascii, podremos
interpretar cual es la traduccion que propones.
Por supuesto, tienes razon es la mejor forma! Me di cuenta en el momento de
enviarlo...
Ademas, pense, que cada usuario, segun el pais, tendra una tabla ascii
distinta y debera adaptar
los codigos de caracter que se traducen por otros codigos de caracter... no
se si me explique...
y me acorde que lo pense cuando hice la funcion (hace meses) pero a mi me
funciono asi !
Tambien faltaria la funcion aPosition(), pero es facilmente creable...
Mi idea era mostrar como se puede crear en puro .prg una funcion oemtoansi()

Saludos

Loading...