Funcion UTF8ToStr()

Funcion UTF8ToStr()

Postby servicomver » Fri May 29, 2015 9:23 pm

Hola, estoy tratando de leer un XML con la funcion UTF8ToStr(), pero al compilarlo me dice que la funcion no se encuentra, debo enlazarlo con alguna libreria o clase ? si es asi donde puedo descargarla ?

Msginfo(HB_UTF8ToStr(cVar ))

Muchas gracias por su ayuda
servicomver
 
Posts: 192
Joined: Fri Nov 18, 2005 7:34 pm

Re: Funcion UTF8ToStr()

Postby karinha » Fri May 29, 2015 9:33 pm

Code: Select all  Expand view  RUN


/*
UTF8

request HB_CODEPAGE_UTF8

viewtopic.php?f=3&t=20561&p=109474&hilit=utf8#p109474

No xHarbour 1.1.0 foi criada a função para converter texto puro para UTF8:

HB_StrToUTF8( cStr ) e HB_UTF8ToStr( cUtf8 )

Exemplo:
*/



REQUEST HB_CODEPAGE_PTISO
REQUEST HB_CODEPAGE_PT850

FUNCTION Acentuacao()

   local cStr, cAsc, cUtf8

   HB_SETCODEPAGE( "PT850" )

   cStr := "Isto é um teste de conversão."

   cUtf8 := hb_strToUTF8( cStr )

   cAsc := hb_UTF8ToStr( cUtf8 )

   ? cStr
   ? cUtf8
   ? cAsc

RETURN NIL
 


João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7872
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Funcion UTF8ToStr()

Postby servicomver » Fri May 29, 2015 10:14 pm

gracias por su apoyo
al compilar me marca el error
Error: Unresolved external HB_FUN_HB_SETCODE
Error: Unresolved external HB_FUN_HB_CODEPAGE_PTISO
Error: Unresolved external HB_FUN_HB_CODEPAGE_PT850

me falta enlazar algo ?
servicomver
 
Posts: 192
Joined: Fri Nov 18, 2005 7:34 pm

Re: Funcion UTF8ToStr()

Postby karinha » Mon Jun 01, 2015 12:04 pm

Code: Select all  Expand view  RUN

request HB_CODEPAGE_UTF8
 


en tu caso debes llhamar la CODEPAGE en espanhol.

Saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7872
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Funcion UTF8ToStr()

Postby karinha » Mon Jun 01, 2015 2:26 pm

Code: Select all  Expand view  RUN

      cStrUtf8 := "Texto en caracteres UTF-8: (dígrafo BR)'ção',(dígrafo espanhol-enhe)'ñ',(trema)'Ü',(ordinais)'ªº',(ligamento s+z alemão)'ß'."

      cUTF8 := HB_STRTOUTF8( cStrUtf8 ) // funcao del XHARBOUR

      cAsc  := HB_UTF8TOSTR( cUtf8 )

      cUTF8Fin := cAsc
 


João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7872
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Funcion UTF8ToStr()

Postby servicomver » Mon Jun 01, 2015 5:35 pm

Hola y greacias por sus respuestas.
Ya intente con lo me han dicho pero aun sigo sin poder llamar la funcion sera que tengo una libreria muy vieja ?, me la pueden mandar ?.

@ECHO OFF
CLS
ECHO ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
ECHO ³ FiveWin for xHarbour 7.01 - January 2007 xHarbour development power ³Ü
ECHO ³ (c) FiveTech, 1993-2006 for Microsoft Windows 95/98/NT/2000/ME and XP ³Û
ECHO ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙÛ
ECHO ÿ ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß


set hdir=c:\xharbour
set bcdir=c:\bcc55
set fwdir=c:\fwh
set lib=%xdir%\lib;%bcdir%\lib;%fwdir%\lib
set include=%xdir%\include;%bcdir%\include;%fwdir%\include

if A%1 == A GOTO :SINTAX
if NOT EXIST %1.prg GOTO :NOEXIST

ECHO Compiling...

%hdir%\bin\harbour %1 /n /i%fwdir%\include;%hdir%\include /w /p %2 %3 > clip.log
%hdir%\bin\harbour wbrowse /n /i%fwdir%\include;%hdir%\include /w /p %2 %3 > clip.log
%hdir%\bin\harbour tmultise /n /i%fwdir%\include;%hdir%\include /w /p %2 %3 > clip.log
%hdir%\bin\harbour pdf1 /n /i%fwdir%\include;%hdir%\include /w /p %2 %3 > clip.log
%hdir%\bin\harbour pdfhbdcs /n /i%fwdir%\include;%hdir%\include /w /p %2 %3 > clip.log

%hdir%\bin\harbour tfilexls /n /i%fwdir%\include;%hdir%\include /w /p %2 %3 > clip.log

%hdir%\bin\harbour tFacturaElectronica /n /i%fwdir%\include;%hdir%\include /w /p %2 %3 > clip.log
%hdir%\bin\harbour tCfdi /n /i%fwdir%\include;%hdir%\include /w /p %2 %3 > clip.log

%hdir%\bin\harbour tGraph /n /i%fwdir%\include;%hdir%\include /w /p %2 %3 > clip.log
%hdir%\bin\harbour tArray /n /i%fwdir%\include;%hdir%\include /w /p %2 %3 > clip.log


@type clip.log
IF ERRORLEVEL 1 PAUSE
IF ERRORLEVEL 1 GOTO EXIT

rem echo -O2 -e%1.exe -I%hdir%\include %1.c > b32.bc
rem %bcdir%\bin\bcc32 -M -c -v @b32.bc

%bcdir%\bin\bcc32 -M -c -v -O2 -I%hdir%\include %1.c
%bcdir%\bin\bcc32 -M -c -v -O2 -I%hdir%\include %wbrowse.c
%bcdir%\bin\bcc32 -M -c -v -O2 -I%hdir%\include %tmultise.c



%bcdir%\bin\bcc32 -M -c -v -O2 -I%hdir%\include %pdf1.c
%bcdir%\bin\bcc32 -M -c -v -O2 -I%hdir%\include %pdfhbdcs.c
%bcdir%\bin\bcc32 -M -c -v -O2 -I%hdir%\include %tfilexls.c

%bcdir%\bin\bcc32 -M -c -v -O2 -I%hdir%\include %tFacturaElectronica.c
%bcdir%\bin\bcc32 -M -c -v -O2 -I%hdir%\include %tCfdi.c

%bcdir%\bin\bcc32 -M -c -v -O2 -I%hdir%\include %tGraph.c
%bcdir%\bin\bcc32 -M -c -v -O2 -I%hdir%\include %tArray.c


%bcdir%\bin\bcc32 -M -c -v -O2 -I%hdir%\include Wrapperpac.cpp


:ENDCOMPILE

IF EXIST %1.rc %bcdir%\bin\brc32 -r %1

echo c0w32.obj + > b32.bc
echo %1.obj codelib.obj wbrowse.obj tmultise.obj wbrwline.obj pdf1.obj pdfhbdcs.obj tfilexls.obj tCfdi.obj tGraph.obj tArray.obj WrapperPac.obj , + >> b32.bc
echo %1.exe, + >> b32.bc
echo %1.map, + >> b32.bc
echo %fwdir%\lib\Fivehx.lib %fwdir%\lib\FiveHC.lib + >> b32.bc
echo %hdir%\lib\rtl.lib + >> b32.bc
echo %hdir%\lib\hbzip.lib + >> b32.bc
echo %hdir%\lib\zlib.lib + >> b32.bc
echo %hdir%\lib\vm.lib + >> b32.bc
echo %hdir%\lib\gtgui.lib + >> b32.bc
echo %hdir%\lib\lang.lib + >> b32.bc
echo %hdir%\lib\macro.lib + >> b32.bc
echo %hdir%\lib\rdd.lib + >> b32.bc
echo %hdir%\lib\dbfntx.lib + >> b32.bc
echo %hdir%\lib\dbfcdx.lib + >> b32.bc
echo %hdir%\lib\dbffpt.lib + >> b32.bc
echo %hdir%\lib\hbsix.lib + >> b32.bc
echo %hdir%\lib\debug.lib + >> b32.bc
echo %hdir%\lib\common.lib + >> b32.bc
echo %hdir%\lib\pp.lib + >> b32.bc
echo %hdir%\lib\ct.lib + >> b32.bc
echo %hdir%\lib\pcrepos.lib + >> b32.bc




echo %hdir%\lib\wbrowse.lib + >> b32.bc
echo %hdir%\lib\tpdfx.lib + >> b32.bc
echo %hdir%\lib\hbole.lib + >> b32.bc
echo %hdir%\lib\filexls.lib + >> b32.bc

rem Uncomment these two lines to use Advantage RDD
rem echo %hdir%\lib\rddads.lib + >> b32.bc
rem echo %hdir%\lib\Ace32.lib + >> b32.bc

echo %bcdir%\lib\cw32.lib + >> b32.bc
echo %bcdir%\lib\import32.lib + >> b32.bc
echo %bcdir%\lib\psdk\odbc32.lib + >> b32.bc
echo %bcdir%\lib\psdk\rasapi32.lib + >> b32.bc
echo %bcdir%\lib\psdk\nddeapi.lib + >> b32.bc
echo %bcdir%\lib\psdk\msimg32.lib + >> b32.bc
echo %bcdir%\lib\psdk\iphlpapi.lib, >> b32.bc


IF EXIST %1.res echo %1.res >> b32.bc

rem uncomment this line to use the debugger and comment the following one
rem %bcdir%\bin\ilink32 -Gn -Tpe -s -v @b32.bc
%bcdir%\bin\ilink32 -Gn -aa -Tpe -s -v @b32.bc

IF ERRORLEVEL 1 GOTO LINKERROR
ECHO * Application successfully built
%1
GOTO EXIT
ECHO

rem delete temporary files
@del %1.c

:LINKERROR
ECHO * There are errors
GOTO EXIT

:SINTAX
ECHO SYNTAX: Build [Program] {-- No especifiques la extensi¢n PRG
ECHO {-- Don't specify .PRG extension
GOTO EXIT

:NOEXIST
ECHO The specified PRG %1 does not exist

:EXIT
servicomver
 
Posts: 192
Joined: Fri Nov 18, 2005 7:34 pm

Re: Funcion UTF8ToStr()

Postby karinha » Mon Jun 01, 2015 5:42 pm

Code: Select all  Expand view  RUN

echo %hdir%\lib\CODEPAGE.lib + >> b32.bc
 


sauldos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7872
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Funcion UTF8ToStr()

Postby servicomver » Tue Jun 02, 2015 9:48 pm

Hola, aun sigo con el problema de lectura del XML
les explico que he hecho
tengo un Archivo el cual inicia:
<?xml version="1.0" encoding="UTF-8"?>
en uno de los nodos hay acentos y "Ñ"

Necesito leerlos correctamente para lo cual
Enlace la libreria CODEPAGE

echo %hdir%\lib\CODEPAGE.lib + >> b32.bc

en el programo llamo asi:
REQUEST HB_CODEPAGE_PTISO //solo prueba y si compila
REQUEST HB_CODEPAGE_ESWIN //prueba y compila sin error
REQUEST HB_LANG_ES //prueba y compila sin error

* REQUEST HB_CODEPAGE_UTF8 //esta es la que necesito y si la desmarco me manda el error:

Error: Unresolved external ´_HB_FUN_CODEPAGE_UTF8

dentro del programa logro poner:
HB_SETCODEPAGE("PTISO")
HB_SETCODEPAGE("ESWIN")

y no genera error.

Mi pregunta es, por que no puedo hacer el REQUEST HB_CODEPAGE_UTF8 ???
Hay alguna otra forma de leer un XML en ese formato para evitar los simbolos raros de los acentos ???

Gracias por su tiempo, y disculpen :D :D
servicomver
 
Posts: 192
Joined: Fri Nov 18, 2005 7:34 pm

Re: Funcion UTF8ToStr()

Postby karinha » Wed Jun 03, 2015 1:09 pm

Mira se ayuda:

Code: Select all  Expand view  RUN

#Include "FiveWin.ch"

REQUEST HB_CODEPAGE_PTISO  // lib: CODEPAGE.LIB de xHarbour
REQUEST HB_CODEPAGE_PT850
REQUEST HB_LANG_PT

FUNCTION Main()

   LOCAL cStr, cAsc, cUtf8

   HB_SETCODEPAGE( "PT850" )  // cambia a espanhol
   HB_LANGSELECT( "PT" )      // cambia a espanhol
   HB_SETCODEPAGE( "UTF8EX" ) // or HB_CDPSELECT( "UTF8EX" )

   cStr := "Isto é um teste de conversão."

   cUtf8 := hb_strToUTF8( cStr )

   cAsc := hb_UTF8ToStr( cUtf8 )

   ? "Texto: ",+ cStr

   ? "Utf8:  ", cUtf8

   ? "Asc:  ", cAsc

RETURN NIL

// fin
 


salu2
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7872
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Funcion UTF8ToStr()

Postby cnavarro » Wed Jun 03, 2015 1:26 pm

HB_TRANSLATE ( <cSrcText>, [<cPageFrom>], [<cPageTo>] ) --> cDstText /* is used usually to convert between the Dos and the Windows code pages of the same language */
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: 6552
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Funcion UTF8ToStr()

Postby karinha » Wed Jun 03, 2015 2:16 pm

ó

Code: Select all  Expand view  RUN

REQUEST HB_CODEPAGE_ESWIN
     
    cAnsi := "áéíóú"
    cUTF8 := HB_STRTOUTF8(cAnsi, "ESWIN")
     
    HB_MemoWrit ("ejemplo.txt", cUTF8)
 
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7872
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 29 guests