Alltrim() help

Post Reply
wartiaga
Posts: 83
Joined: Wed May 25, 2016 1:04 am

Alltrim() help

Post 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!
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Alltrim() help

Post 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 ) )
 
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
wartiaga
Posts: 83
Joined: Wed May 25, 2016 1:04 am

Re: Alltrim() help

Post 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.
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Alltrim() help

Post by cnavarro »

Use

Code: Select all

cStr   := StrTran( cStr, Chr( 160 ), " " )
 
https://stackoverflow.com/questions/279 ... th-numbers
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Alltrim() help

Post 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 )
 
João Santos - São Paulo - Brasil
wartiaga
Posts: 83
Joined: Wed May 25, 2016 1:04 am

Re: Alltrim() help

Post 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.
wartiaga
Posts: 83
Joined: Wed May 25, 2016 1:04 am

Re: Alltrim() help

Post 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.
Post Reply