FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Alltrim() help
Posts: 253
Joined: Wed May 25, 2016 01:04 AM
Alltrim() help
Posted: Wed Feb 26, 2020 01: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!

Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Alltrim() help
Posted: 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 (fw): Select all Collapse
? 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
Posts: 253
Joined: Wed May 25, 2016 01:04 AM
Re: Alltrim() help
Posted: 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 (fw): Select all Collapse
? 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.
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Alltrim() help
Posted: Wed Feb 26, 2020 12:54 PM
Use
Code (fw): Select all Collapse
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
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Alltrim() help
Posted: Wed Feb 26, 2020 01:37 PM
http://fivewin.com.br/index.php?/topic/28336-pequisa-aven%C3%A7ada/

Code (fw): Select all Collapse
   // 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
Posts: 253
Joined: Wed May 25, 2016 01:04 AM
Re: Alltrim() help
Posted: Wed Feb 26, 2020 03:34 PM
karinha wrote:http://fivewin.com.br/index.php?/topic/28336-pequisa-aven%C3%A7ada/

Code (fw): Select all Collapse
   // 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.
Posts: 253
Joined: Wed May 25, 2016 01:04 AM
Re: Alltrim() help
Posted: Wed Feb 26, 2020 03:34 PM
cnavarro wrote:Use
Code (fw): Select all Collapse
cStr   := StrTran( cStr, Chr( 160 ), " " )


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


Thank you! I will try.

Continue the discussion