Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #8529

Re: create txt file with utf-8

From "Uwe Heyer" <uwe.heyer@aristik.de>
Newsgroups comp.lang.clipper.visual-objects
Subject Re: create txt file with utf-8
Date 2015-10-16 20:18 +0000
Message-ID <d8d4d4FqgidU1@mid.individual.net> (permalink)
References <aa3c9200-dde0-4184-b8ab-fcb7310dc076@googlegroups.com>

Show all headers | View raw


moshe attia wrote:

> hi
> it create txt file 
> and write the data in the file
> i need to write the file at utf-8 format
> 
> .
> the project dump dbf file to svc  
> and import the svc to mysql .
> 
> when i import the file i recive at varchar  ?????????
> 
> 
> moshe

-- 

Hi moshe,

you need a convert to wide_char first

MultiByteToWideChar(CP_ACP, ....)


second, convert above result to multi_byte

WideCharToMultiByte(CP_UTF8, ...)


first of both calls is the compute of needed spaces


see below (an example in Power Basic)


' Konvertiert ANSI nach UTF-8
FUNCTION PBAnsiToUtf8(BYVAL sString AS STRING) EXPORT AS STRING

    LOCAL sBuffer AS STRING
    LOCAL nLength AS LONG

    nLength = MultiByteToWideChar(%CP_ACP, 0, BYVAL STRPTR(sString),
-1, BYVAL 0, 0)
    sBuffer = NUL$(nLength * 2)
    MultiByteToWideChar(%CP_ACP, 0, BYVAL STRPTR(sString), -1, BYVAL
STRPTR(sBuffer), nLength)

    nLength = WideCharToMultiByte(%CP_UTF8, 0, BYVAL STRPTR(sBuffer),
-1, BYVAL 0, 0, BYVAL (0), BYVAL (0))
    sString = NUL$(nLength)
    WideCharToMultiByte(%CP_UTF8, 0, BYVAL STRPTR(sBuffer), -1, BYVAL
STRPTR(sString), nLength, BYVAL (0), BYVAL (0))

    FUNCTION = LEFT$(sString, LEN(sString) - 1)

END FUNCTION

Ahoj
-Uwe




Back to comp.lang.clipper.visual-objects | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

create txt file with utf-8 moshe attia <attiamx@gmail.com> - 2015-10-16 08:35 -0700
  Re: create txt file with utf-8 D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2015-10-16 20:05 +0200
    Re: create txt file with utf-8 Karl Faller <mail_withoutthat_@_drei-f_andthat_.de> - 2015-10-16 20:50 +0200
      Re: create txt file with utf-8 D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2015-10-19 11:54 +0200
        Re: create txt file with utf-8 Karl Faller <mail_withoutthat_@_drei-f_andthat_.de> - 2015-10-19 14:01 +0200
          Re: create txt file with utf-8 D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2015-10-20 19:59 +0200
            Re: create txt file with utf-8 Karl Faller <mail_withoutthat_@_drei-f_andthat_.de> - 2015-10-20 21:52 +0200
  Re: create txt file with utf-8 "Uwe Heyer" <uwe.heyer@aristik.de> - 2015-10-16 20:18 +0000
  Re: create txt file with utf-8 moshe attia <attiamx@gmail.com> - 2015-10-17 13:48 -0700
    Re: create txt file with utf-8 "Arne Ortlinghaus" <Arne.Ortlinghaus@acs.it> - 2015-10-21 17:00 +0200

csiph-web