Alltrim() help

Alltrim() help

Postby wartiaga » Wed Feb 26, 2020 1:06 am

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

Re: Alltrim() help

Postby cnavarro » Wed Feb 26, 2020 10:25 am

Yes, AllTrim is used for remove blank spaces at end and at begining
Please, put this code
Code: Select all  Expand view  RUN

? Asc( Right( Alltrim(oArqCli:ENDERECO), 1 ) ) == 32
? Asc( Right( Alltrim(oArqCli:ENDERECO), 1 ) )
 
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Alltrim() help

Postby wartiaga » Wed Feb 26, 2020 12:36 pm

cnavarro wrote:Yes, AllTrim is used for remove blank spaces at end and at begining
Please, put this code
Code: Select all  Expand view  RUN

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

Re: Alltrim() help

Postby cnavarro » Wed Feb 26, 2020 12:54 pm

Use
Code: Select all  Expand view  RUN

cStr   := StrTran( cStr, Chr( 160 ), " " )
 


https://stackoverflow.com/questions/279 ... th-numbers
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Alltrim() help

Postby karinha » Wed Feb 26, 2020 1:37 pm

http://fivewin.com.br/index.php?/topic/28336-pequisa-aven%C3%A7ada/

Code: Select all  Expand view  RUN

   // 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 - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7842
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Alltrim() help

Postby wartiaga » Wed Feb 26, 2020 3:34 pm

karinha wrote:http://fivewin.com.br/index.php?/topic/28336-pequisa-aven%C3%A7ada/

Code: Select all  Expand view  RUN

   // 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: 212
Joined: Wed May 25, 2016 1:04 am

Re: Alltrim() help

Postby wartiaga » Wed Feb 26, 2020 3:34 pm

cnavarro wrote:Use
Code: Select all  Expand view  RUN

cStr   := StrTran( cStr, Chr( 160 ), " " )
 


https://stackoverflow.com/questions/279 ... th-numbers


Thank you! I will try.
wartiaga
 
Posts: 212
Joined: Wed May 25, 2016 1:04 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 55 guests