Hola a todos
He estado buscando en el foro alguna solución al tema de los acentos y las "Ñ" y "ñ" en Xbrowse pero solo he encontrado una cuestión que se planteó, pero sin respuesta:
https://forums.fivetechsupport.com/viewtopic.php?f=6&t=36819&start=0&hilit=xbrowse+acentos+y+%C3%91&sid=80d63a6e7695b57e10b2dbf8a1abbf5e
Alguien ha podido dar con la solución?
Saludos
xBrwowse acentos y Ñ/ñ [SOLUCIONADO]
xBrwowse acentos y Ñ/ñ [SOLUCIONADO]
Last edited by Ramón J. on Tue Dec 14, 2021 9:55 am, edited 1 time in total.
FWH 20.12 BCC7
- karinha
- Posts: 7948
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: xBrwowse acentos y Ñ/ñ
Intenta asi:
Regards, saludos.
Code: Select all | Expand
// \samples\ACENTUAR.PRG
#Include "FiveWin.ch"
REQUEST HB_CODEPAGE_PTISO
REQUEST HB_CODEPAGE_UTF8EX
REQUEST HB_LANG_ES
REQUEST HB_CODEPAGE_ESWIN // Para reconocer la EÑE y ACENTOS en los índices
Procedure Main()
// texto a converter
LOCAL cStr := hb_utf8tostr( hb_memoread( 'utf8.txt' ) ) // Aten‡Æo / Adi‡Æo
HB_CDPSELECT( "PTISO" )
hb_cdpSelect( "UTF8EX" )
HB_LANGSELECT ( "ES" ) // Idioma Español
HB_SetCodePage ( "ESWIN" ) // Para reconocer la EÑE y ACENTOS en los índices
? 'Directly : ', cStr
? 'UTF8toSTR : ',hb_utf8tostr( cStr )
? 'OemToAnsi + UTF8toSTR: ',hb_OemToAnsi( hb_utf8tostr( cStr ) )
? 'AnsiToOem + UTF8toSTR: ',hb_AnsiToOem( hb_utf8tostr( cStr ) )
? 'UTF8toSTR + OemToAnsi: ',hb_utf8tostr( hb_OemToAnsi( cStr ) )
? 'UTF8toSTR + AnsiToOem: ',hb_utf8tostr( hb_AnsiToOem( cStr ) )
? 'OemToAnsi : ',hb_OemToAnsi( cStr )
? 'AnsiToOem : ',hb_AnsiToOem( cStr )
cStr := hb_utf8tostr( memoread( 'utf8.txt' ) )
? 'Directly : ', cStr
? 'UTF8toSTR : ',hb_utf8tostr( cStr )
? 'OemToAnsi + UTF8toSTR: ',hb_OemToAnsi( hb_utf8tostr( cStr ) )
? 'AnsiToOem + UTF8toSTR: ',hb_AnsiToOem( hb_utf8tostr( cStr ) )
? 'UTF8toSTR + OemToAnsi: ',hb_utf8tostr( hb_OemToAnsi( cStr ) )
? 'UTF8toSTR + AnsiToOem: ',hb_utf8tostr( hb_AnsiToOem( cStr ) )
? 'OemToAnsi : ',hb_OemToAnsi( cStr )
? 'AnsiToOem : ',hb_AnsiToOem( cStr )
cStr := hb_memoread( 'utf8.txt' )
? 'Directly : ', cStr
? 'UTF8toSTR : ',hb_utf8tostr( cStr )
? 'OemToAnsi + UTF8toSTR: ',hb_OemToAnsi( hb_utf8tostr( cStr ) )
? 'AnsiToOem + UTF8toSTR: ',hb_AnsiToOem( hb_utf8tostr( cStr ) )
? 'UTF8toSTR + OemToAnsi: ',hb_utf8tostr( hb_OemToAnsi( cStr ) )
? 'UTF8toSTR + AnsiToOem: ',hb_utf8tostr( hb_AnsiToOem( cStr ) )
? 'OemToAnsi : ',hb_OemToAnsi( cStr )
? 'AnsiToOem : ',hb_AnsiToOem( cStr )
cStr := memoread( 'utf8.txt' )
? 'Directly : ', cStr
? 'UTF8toSTR : ',hb_utf8tostr( cStr )
? 'OemToAnsi + UTF8toSTR: ',hb_OemToAnsi( hb_utf8tostr( cStr ) )
? 'AnsiToOem + UTF8toSTR: ',hb_AnsiToOem( hb_utf8tostr( cStr ) )
? 'UTF8toSTR + OemToAnsi: ',hb_utf8tostr( hb_OemToAnsi( cStr ) )
? 'UTF8toSTR + AnsiToOem: ',hb_utf8tostr( hb_AnsiToOem( cStr ) )
? 'OemToAnsi : ',hb_OemToAnsi( cStr )
? 'AnsiToOem : ',hb_AnsiToOem( cStr )
Return Nil
// fin / end
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Re: xBrwowse acentos y Ñ/ñ
Muchas gracias, por tu atención. Como siempre en primera línea dispuesto a ayudar.
Perdona mi torpeza, pero no acabo de entender tu ejemplo con el utf8.txt. Te mando tu ejemplo modificado cambiando el txt por variables. No sé si está bien planteada la consulta, pero la cuestión es que, según la gramática española, todas las palabras que tengan tildes hay ponerlas, sean en minúsculas o en mayúsculas. Desgraciadamente, aquí en España y con el castellano, se está incurriendo constantemente en el error de no poner tildes en las mayúsculas e incluso en las minúsculas.
Por ejemplo: VALÈNCIA ,València, PERÚ, Perú, BOGOTÁ, Bogotá tienen tilde y hay ponerlas, tanto si son en minúsculas como en mayúsculas. Y además se contemplan los tipos de tildes abiertas o cerradas según el dialecto de cada comunidad autónoma (València tiene tilde cerrada, propia del dialecto).
Lo curioso es que el problema aparece en Xbrowse, porque cuando editas el registro con un odlg los datos se muestran correctamente. Te mando una captura de pantalla

Saludos y gracias
Perdona mi torpeza, pero no acabo de entender tu ejemplo con el utf8.txt. Te mando tu ejemplo modificado cambiando el txt por variables. No sé si está bien planteada la consulta, pero la cuestión es que, según la gramática española, todas las palabras que tengan tildes hay ponerlas, sean en minúsculas o en mayúsculas. Desgraciadamente, aquí en España y con el castellano, se está incurriendo constantemente en el error de no poner tildes en las mayúsculas e incluso en las minúsculas.
Por ejemplo: VALÈNCIA ,València, PERÚ, Perú, BOGOTÁ, Bogotá tienen tilde y hay ponerlas, tanto si son en minúsculas como en mayúsculas. Y además se contemplan los tipos de tildes abiertas o cerradas según el dialecto de cada comunidad autónoma (València tiene tilde cerrada, propia del dialecto).
Lo curioso es que el problema aparece en Xbrowse, porque cuando editas el registro con un odlg los datos se muestran correctamente. Te mando una captura de pantalla

Code: Select all | Expand
#Include "FiveWin.ch"
REQUEST HB_CODEPAGE_PTISO
REQUEST HB_CODEPAGE_UTF8EX
REQUEST HB_LANG_ES
REQUEST HB_CODEPAGE_ESWIN // Para reconocer la EÑE y ACENTOS en los índices
Procedure Main()
// texto a converter
//LOCAL cStr := hb_utf8tostr( hb_memoread( 'utf8.txt' ) ) // Aten‡Æo / Adi‡Æo
Local cStr := "PEÑÀGUILA, Peñàguila, TURÍS, Turís, CÀLIG, Càlig, XÀTIVA, Xàtiva, AGROCÍTRICOS, Agocítricos, L'ALCÚDIA, L'Alcúdia"+CRLF+;
"ÁGORA, Ágora, ALMÀSSERA, Almàssera, PERÚ, Perú, BOGOTÁ, Bogotá, VALÈNCIA, València"
HB_CDPSELECT( "PTISO" )
hb_cdpSelect( "UTF8EX" )
HB_LANGSELECT ( "ES" ) // Idioma Español
HB_SetCodePage ( "ESWIN" ) // Para reconocer la EÑE y ACENTOS en los índices
? 'Directly : ', cStr
? 'UTF8toSTR : ',hb_utf8tostr( cStr )
? 'OemToAnsi + UTF8toSTR: ',hb_OemToAnsi( hb_utf8tostr( cStr ) )
? 'AnsiToOem + UTF8toSTR: ',hb_AnsiToOem( hb_utf8tostr( cStr ) )
? 'UTF8toSTR + OemToAnsi: ',hb_utf8tostr( hb_OemToAnsi( cStr ) )
? 'UTF8toSTR + AnsiToOem: ',hb_utf8tostr( hb_AnsiToOem( cStr ) )
? 'OemToAnsi : ',hb_OemToAnsi( cStr )
? 'AnsiToOem : ',hb_AnsiToOem( cStr )
// cStr := hb_utf8tostr( memoread( 'utf8.txt' ) )
? 'Directly : ', cStr
? 'UTF8toSTR : ',hb_utf8tostr( cStr )
? 'OemToAnsi + UTF8toSTR: ',hb_OemToAnsi( hb_utf8tostr( cStr ) )
? 'AnsiToOem + UTF8toSTR: ',hb_AnsiToOem( hb_utf8tostr( cStr ) )
? 'UTF8toSTR + OemToAnsi: ',hb_utf8tostr( hb_OemToAnsi( cStr ) )
? 'UTF8toSTR + AnsiToOem: ',hb_utf8tostr( hb_AnsiToOem( cStr ) )
? 'OemToAnsi : ',hb_OemToAnsi( cStr )
? 'AnsiToOem : ',hb_AnsiToOem( cStr )
// cStr := hb_memoread( 'utf8.txt' )
? 'Directly : ', cStr
? 'UTF8toSTR : ',hb_utf8tostr( cStr )
? 'OemToAnsi + UTF8toSTR: ',hb_OemToAnsi( hb_utf8tostr( cStr ) )
? 'AnsiToOem + UTF8toSTR: ',hb_AnsiToOem( hb_utf8tostr( cStr ) )
? 'UTF8toSTR + OemToAnsi: ',hb_utf8tostr( hb_OemToAnsi( cStr ) )
? 'UTF8toSTR + AnsiToOem: ',hb_utf8tostr( hb_AnsiToOem( cStr ) )
? 'OemToAnsi : ',hb_OemToAnsi( cStr )
? 'AnsiToOem : ',hb_AnsiToOem( cStr )
// cStr := memoread( 'utf8.txt' )
? 'Directly : ', cStr
? 'UTF8toSTR : ',hb_utf8tostr( cStr )
? 'OemToAnsi + UTF8toSTR: ',hb_OemToAnsi( hb_utf8tostr( cStr ) )
? 'AnsiToOem + UTF8toSTR: ',hb_AnsiToOem( hb_utf8tostr( cStr ) )
? 'UTF8toSTR + OemToAnsi: ',hb_utf8tostr( hb_OemToAnsi( cStr ) )
? 'UTF8toSTR + AnsiToOem: ',hb_utf8tostr( hb_AnsiToOem( cStr ) )
? 'OemToAnsi : ',hb_OemToAnsi( cStr )
? 'AnsiToOem : ',hb_AnsiToOem( cStr )
Return Nil
Saludos y gracias
FWH 20.12 BCC7
- karinha
- Posts: 7948
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: xBrwowse acentos y Ñ/ñ
Code: Select all | Expand
// \samples\ACENTUAR.PRG - 2.0
#Include "FiveWin.ch"
REQUEST HB_CODEPAGE_PTISO
REQUEST HB_CODEPAGE_UTF8EX
REQUEST HB_LANG_ES
REQUEST HB_CODEPAGE_ESWIN // Para reconocer la EÑE y ACENTOS en los índices
Procedure Main()
// texto a converter
// LOCAL cStr := hb_utf8tostr( hb_memoread( 'utf8.txt' ) ) // Aten‡Æo / Adi‡Æo
LOCAL cStr := "XÀTIVA"
HB_CDPSELECT( "PTISO" )
hb_cdpSelect( "UTF8EX" )
HB_LANGSELECT ( "ES" ) // Idioma Español
HB_SetCodePage ( "ESWIN" ) // Para reconocer la EÑE y ACENTOS en los índices
? 'Directly 1 : ', cStr
? 'UTF8toSTR : ',hb_utf8tostr( cStr )
? 'OemToAnsi + UTF8toSTR: ',hb_OemToAnsi( hb_utf8tostr( cStr ) )
? 'AnsiToOem + UTF8toSTR: ',hb_AnsiToOem( hb_utf8tostr( cStr ) )
? 'UTF8toSTR + OemToAnsi: ',hb_utf8tostr( hb_OemToAnsi( cStr ) )
? 'UTF8toSTR + AnsiToOem: ',hb_utf8tostr( hb_AnsiToOem( cStr ) )
? 'OemToAnsi : ',hb_OemToAnsi( cStr )
? 'AnsiToOem : ',hb_AnsiToOem( cStr )
// cStr := hb_utf8tostr( memoread( 'utf8.txt' ) )
? 'Directly 2 : ', cStr
? 'UTF8toSTR : ',hb_utf8tostr( cStr )
? 'OemToAnsi + UTF8toSTR: ',hb_OemToAnsi( hb_utf8tostr( cStr ) )
? 'AnsiToOem + UTF8toSTR: ',hb_AnsiToOem( hb_utf8tostr( cStr ) )
? 'UTF8toSTR + OemToAnsi: ',hb_utf8tostr( hb_OemToAnsi( cStr ) )
? 'UTF8toSTR + AnsiToOem: ',hb_utf8tostr( hb_AnsiToOem( cStr ) )
? 'OemToAnsi : ',hb_OemToAnsi( cStr )
? 'AnsiToOem : ',hb_AnsiToOem( cStr )
// cStr := hb_memoread( 'utf8.txt' )
? 'Directly 3 : ', cStr
? 'UTF8toSTR : ',hb_utf8tostr( cStr )
? 'OemToAnsi + UTF8toSTR: ',hb_OemToAnsi( hb_utf8tostr( cStr ) )
? 'AnsiToOem + UTF8toSTR: ',hb_AnsiToOem( hb_utf8tostr( cStr ) )
? 'UTF8toSTR + OemToAnsi: ',hb_utf8tostr( hb_OemToAnsi( cStr ) )
? 'UTF8toSTR + AnsiToOem: ',hb_utf8tostr( hb_AnsiToOem( cStr ) )
? 'OemToAnsi : ',hb_OemToAnsi( cStr )
? 'AnsiToOem : ',hb_AnsiToOem( cStr )
// cStr := memoread( 'utf8.txt' )
? 'Directly 4 : ', cStr
? 'UTF8toSTR : ',hb_utf8tostr( cStr )
? 'OemToAnsi + UTF8toSTR: ',hb_OemToAnsi( hb_utf8tostr( cStr ) )
? 'AnsiToOem + UTF8toSTR: ',hb_AnsiToOem( hb_utf8tostr( cStr ) )
? 'UTF8toSTR + OemToAnsi: ',hb_utf8tostr( hb_OemToAnsi( cStr ) )
? 'UTF8toSTR + AnsiToOem: ',hb_utf8tostr( hb_AnsiToOem( cStr ) )
? 'OemToAnsi : ',hb_OemToAnsi( cStr )
? 'AnsiToOem : ',hb_AnsiToOem( cStr )
Return Nil
Saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Re: xBrwowse acentos y Ñ/ñ
Muchas gracias, João
He modificado algunas cosas de tu ejemplo y funciona. Contempla las tildes abiertas y cerradas, la diéresis y las "ñ", tanto en mayúsculas como en minúsculas.
He cambiado REQUEST HB_CODEPAGE_PTISO por REQUEST HB_CODEPAGE_ES850 ya que el primero corresponde al idioma portugués.
Y dentro de la función he cambiado HB_CDPSELECT( "PTISO" ) por HB_SETCODEPAGE( "ES850" ) por la misma razón.
El ejemplo completo y simplificado quedaría así, incluyendo palabras con tildes abiertas y cerradas, diéresis y "ñ", tanto en mayúsculas como en minúsculas:
Y un pequeño detalle muy importante en el que, por pura mecánica, no caemos -o por lo menos no he caido yo- : los PRG se tienen que guardar en forma UTF-8 y no en ANSI como, a veces y por defecto, ocurre.
Un saludo y muchas gracias João
He modificado algunas cosas de tu ejemplo y funciona. Contempla las tildes abiertas y cerradas, la diéresis y las "ñ", tanto en mayúsculas como en minúsculas.
He cambiado REQUEST HB_CODEPAGE_PTISO por REQUEST HB_CODEPAGE_ES850 ya que el primero corresponde al idioma portugués.
Y dentro de la función he cambiado HB_CDPSELECT( "PTISO" ) por HB_SETCODEPAGE( "ES850" ) por la misma razón.
El ejemplo completo y simplificado quedaría así, incluyendo palabras con tildes abiertas y cerradas, diéresis y "ñ", tanto en mayúsculas como en minúsculas:
Code: Select all | Expand
#Include "FiveWin.ch"
//REQUEST HB_CODEPAGE_PTISO // Se quita por ser del idioma portugués
REQUEST HB_CODEPAGE_UTF8EX
REQUEST HB_LANG_ES
REQUEST HB_CODEPAGE_ESWIN // Para reconocer la EÑE y ACENTOS en los índices
REQUEST HB_CODEPAGE_ES850 // Se añade el idioma español
Procedure Main()
LOCAL cStr := "PEÑÀGUILA, Peñàguila, TURÍS, Turís, CÀLIG, Càlig, XÀTIVA, Xàtiva, AGROCÍTRICOS, Agrocítricos, L'ALCÚDIA, L'Alcúdia"+CRLF+;
"ÁGORA, Ágora, ALMÀSSERA, Almàssera, PERÚ, Perú, BOGOTÁ, Bogotá, VALÈNCIA, València, ZARIGÜEÑA, Zarigüeña"
HB_SETCODEPAGE( "ES850" ) // Se añade el código de página del idioma español
//HB_CDPSELECT( "PTISO" ) // Se quita por corresponder al idioma portugués
hb_cdpSelect( "UTF8EX" )
HB_LANGSELECT ( "ES" ) // Idioma Español
HB_SetCodePage ( "ESWIN" ) // Para reconocer la EÑE y ACENTOS en los índices
? 'UTF8toSTR : ',hb_utf8tostr( cStr )
Return nil
Y un pequeño detalle muy importante en el que, por pura mecánica, no caemos -o por lo menos no he caido yo- : los PRG se tienen que guardar en forma UTF-8 y no en ANSI como, a veces y por defecto, ocurre.
Un saludo y muchas gracias João
FWH 20.12 BCC7
- karinha
- Posts: 7948
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: xBrwowse acentos y Ñ/ñ [SOLUCIONADO]
Mui bién Ramón. Voy guardar para el futuro. Muchas gracias por el aporte.
Regards, saludos.
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
- karinha
- Posts: 7948
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: xBrwowse acentos y Ñ/ñ [SOLUCIONADO]
Code: Select all | Expand
// \SAMPLES\RAMONUTF.PRG - Harbour / xHarbour compiler
#Include "FiveWin.ch"
#Include "HbCompat.ch"
// REQUEST HB_CODEPAGE_PTISO // Se quita por ser del idioma portugués
REQUEST HB_CODEPAGE_UTF8EX
REQUEST HB_LANG_ES
REQUEST HB_CODEPAGE_ESWIN // Para reconocer la EÑE y ACENTOS en los índices
REQUEST HB_CODEPAGE_ES850 // Se añade el idioma español
FUNCTION Main()
LOCAL cStr := "PEÑÀGUILA, Peñàguila, TURÍS, Turís, CÀLIG, Càlig, XÀTIVA, Xàtiva, AGROCÍTRICOS, Agrocítricos, L'ALCÚDIA, L'Alcúdia"+CRLF+;
"ÁGORA, Ágora, ALMÀSSERA, Almàssera, PERÚ, Perú, BOGOTÁ, Bogotá, VALÈNCIA, València, ZARIGÜEÑA, Zarigüeña"
HB_SETCODEPAGE( "ES850" ) // Se añade el código de página del idioma español
// HB_CDPSELECT( "PTISO" ) // Se quita por corresponder al idioma portugués
hb_cdpSelect( "UTF8EX" )
HB_LANGSELECT ( "ES" ) // Idioma Español
HB_SetCodePage ( "ESWIN" ) // Para reconocer la EÑE y ACENTOS en los índices
? 'UTF8toSTR : ', hb_utf8tostr( cStr )
RETURN NIL
// FIN / END
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341