Page 1 of 1

Alltrim() help

Posted: Wed Feb 26, 2020 1:06 am
by wartiaga
Hi guys,

I have this line code:

fwrite(marq,'<xLgr>'+Alltrim(oArqCli:ENDERECO)+'</xLgr>'+mfim)

Just fine but in some cases a blank caracter apears in xml (end of oArqCli:ENDERECO field) like this:

<xLgr>RUA 2 QD 13 LT 15 </xLgr>

Shouldn't Alltrim() remove whites at the beginning and end?

Thanks!

Re: Alltrim() help

Posted: Wed Feb 26, 2020 10:25 am
by cnavarro
Yes, AllTrim is used for remove blank spaces at end and at begining
Please, put this code

Code: Select all

? Asc( Right( Alltrim(oArqCli:ENDERECO), 1 ) ) == 32
? Asc( Right( Alltrim(oArqCli:ENDERECO), 1 ) )
 

Re: Alltrim() help

Posted: Wed Feb 26, 2020 12:36 pm
by wartiaga
cnavarro wrote:Yes, AllTrim is used for remove blank spaces at end and at begining
Please, put this code

Code: Select all

? Asc( Right( Alltrim(oArqCli:ENDERECO), 1 ) ) == 32
? Asc( Right( Alltrim(oArqCli:ENDERECO), 1 ) )
 
Hi cnavarro,

The result:

.F.
160

In asc table 160 = á
How this is possible? I don't see á but a space. How I can avoid this?
Thanks in advance.

Re: Alltrim() help

Posted: Wed Feb 26, 2020 12:54 pm
by cnavarro
Use

Code: Select all

cStr   := StrTran( cStr, Chr( 160 ), " " )
 
https://stackoverflow.com/questions/279 ... th-numbers

Re: Alltrim() help

Posted: Wed Feb 26, 2020 1:37 pm
by karinha
http://fivewin.com.br/index.php?/topic/ ... %C3%A7ada/

Code: Select all

   // Endereco/Calle/Direccion
   cDocXml = TIRA_ACENTUACAO( oArqCli:ENDERECO )

   ? cDocXml

FUNCTION TIRA_ACENTUACAO( cStr )

   LOCAL cStrNew := "", nX

   cAcentos := { "‡", "A", "—", "ƒ", "Æ", "Ç", " ", "µ", "…", "·", "‚", "É", "ê", "ˆ", "", "Ò", "í", "Í", "ó", "¢", "à", "ä", "å", "“", "â", "ú", "é", "", "š", "ç", "€", "ã", "Ã", "á", "Á", "à", "À", "é", "É", "ê", "Ê", "í", "Í", "ó", "Ó", "õ", "Õ", "ô", "Ô", "ú", "Ú", "ü", "Ü", "ç", "ù", "AAO", "§", "¦", "º", "ª", "€", "‡", "Ç", "ç", "'", "`", "ø", "¡", "Þ", "×", "Ø", "ÿ", "Ö", CHR(160), CHR(239) }
   cLetras  := { "C", "A", "U", "A", "A", "A", "A", "A", "A", "A", "E", "E", "E", "E", "E", "E", "I", "I", "O", "O", "O", "O", "O", "O", "O", "U", "U", "U", "U", "C", "C", "A", "A", "A", "A", "A", "A", "E", "E", "E", "E", "I", "I", "O", "O", "O", "O", "O", "O", "U", "U", "U", "U", "C", " ", "AAO", ".", ".", ".", ".", "C", "C", "C", "C", "" , "" , ".", "I", "I", "I", "I", "", "I",  "", ""  }

   FOR nX := 1 TO LEN( cAcentos )

      cStrNew := StrTran( cStr, cAcentos[nX], cLetras[nX] )

      cStr := cStrNew

   NEXT

RETURN( cStrNew )
 

Re: Alltrim() help

Posted: Wed Feb 26, 2020 3:34 pm
by wartiaga
karinha wrote:http://fivewin.com.br/index.php?/topic/ ... %C3%A7ada/

Code: Select all

   // Endereco/Calle/Direccion
   cDocXml = TIRA_ACENTUACAO( oArqCli:ENDERECO )

   ? cDocXml

FUNCTION TIRA_ACENTUACAO( cStr )

   LOCAL cStrNew := "", nX

   cAcentos := { "‡", "A", "—", "ƒ", "Æ", "Ç", " ", "µ", "…", "·", "‚", "É", "ê", "ˆ", "", "Ò", "í", "Í", "ó", "¢", "à", "ä", "å", "“", "â", "ú", "é", "", "š", "ç", "€", "ã", "Ã", "á", "Á", "à", "À", "é", "É", "ê", "Ê", "í", "Í", "ó", "Ó", "õ", "Õ", "ô", "Ô", "ú", "Ú", "ü", "Ü", "ç", "ù", "AAO", "§", "¦", "º", "ª", "€", "‡", "Ç", "ç", "'", "`", "ø", "¡", "Þ", "×", "Ø", "ÿ", "Ö", CHR(160), CHR(239) }
   cLetras  := { "C", "A", "U", "A", "A", "A", "A", "A", "A", "A", "E", "E", "E", "E", "E", "E", "I", "I", "O", "O", "O", "O", "O", "O", "O", "U", "U", "U", "U", "C", "C", "A", "A", "A", "A", "A", "A", "E", "E", "E", "E", "I", "I", "O", "O", "O", "O", "O", "O", "U", "U", "U", "U", "C", " ", "AAO", ".", ".", ".", ".", "C", "C", "C", "C", "" , "" , ".", "I", "I", "I", "I", "", "I",  "", ""  }

   FOR nX := 1 TO LEN( cAcentos )

      cStrNew := StrTran( cStr, cAcentos[nX], cLetras[nX] )

      cStr := cStrNew

   NEXT

RETURN( cStrNew )
 
Thanks but in this especific case the content "SAO MATHEUS " your function change the value to SAOAMATHEUSAAAAAAAAAAAAAAAAAAAA, not work.

Re: Alltrim() help

Posted: Wed Feb 26, 2020 3:34 pm
by wartiaga
cnavarro wrote:Use

Code: Select all

cStr   := StrTran( cStr, Chr( 160 ), " " )
 
https://stackoverflow.com/questions/279 ... th-numbers
Thank you! I will try.