FileSystemObject - leer fichero de texto, líneas con acentos

08/04/2010 - 10:48 por Eva | Informe spam
Hola :)

Access 2000, abro un fichero de texto con FileSystemObject (he probado con
OpenAsTextStream y OpenTextFile), en el fichero tengo una línea tal que:

EDIFICACIÓN LOGISTICA INDUSTRIAL

Al leer esta línea con ReadLine obtengo:

EDIFICACIà"N LOGISTICA INDUSTRIAL

¿Qué hago mal? Gracias mil :)))))

Eva

Preguntas similare

Leer las respuestas

#11 Patxi Sanz
18/04/2010 - 15:52 | Informe spam
Creo que te has dejado una función ;-)

- sUTF8ToUni

Un saludo,


Patxi Sanz
Tudela (NA)
http://www.pasa.es.tt/
Respuesta Responder a este mensaje
#12 EnricV
21/04/2010 - 13:03 | Informe spam
Perdón, ahí va el modulo entero.


Option Compare Database
Option Explicit
Private Const CP_UTF8 = 65001

Private Declare Function MultiByteToWideChar Lib "kernel32" ( _
ByVal CodePage As Long, ByVal dwFlags As Long, _
ByVal lpMultiByteStr As Long, ByVal cchMultiByte As Long, _
ByVal lpWideCharStr As Long, ByVal cchWideChar As Long) As Long

Public Function sUTF8ToUni(bySrc() As Byte) As String
' Converts a UTF-8 byte array to a Unicode string
Dim lBytes As Long, lNC As Long, lRet As Long

lBytes = UBound(bySrc) - LBound(bySrc) + 1
lNC = lBytes
sUTF8ToUni = String$(lNC, Chr(0))
lRet = MultiByteToWideChar(CP_UTF8, 0,
VarPtr(bySrc(LBound(bySrc))), lBytes, StrPtr(sUTF8ToUni), lNC)
sUTF8ToUni = Left$(sUTF8ToUni, lRet)
End Function

Public Function ConvertUTF8File(sUTF8File As String, sANSIFile As
String) As String
Dim iFile As Integer, bData() As Byte, sData As String, lSize As Long

' Get the incoming data size
lSize = FileLen(sUTF8File)
If lSize > 0 Then
ReDim bData(0 To lSize - 1)

' Read the existing UTF-8 file
iFile = FreeFile()
Open sUTF8File For Binary As #iFile
Get #iFile, , bData
Close #iFile

' Convert all the data to Unicode (all VB Strings are Unicode)
sData = sUTF8ToUni(bData)
Else
sData = ""
End If

' Now write it all out to the ANSI file
iFile = FreeFile()
Open sANSIFile For Output As #iFile
Print #iFile, sData
Close iFile
'ahora le llamo como al ansii, para pasarselo a la otra func
ConvertUTF8File = sANSIFile

End Function
Respuesta Responder a este mensaje
#13 Patxi Sanz
21/04/2010 - 18:11 | Informe spam
Ahora sí. Y gracias por postearlo :-)

Un saludo,


Patxi Sanz
Tudela (NA)
http://www.pasa.es.tt/
Respuesta Responder a este mensaje
#14 EnricV
22/04/2010 - 17:30 | Informe spam
Salud y vida al grupo.

Venga
email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una pregunta AnteriorRespuesta Tengo una respuesta
Search Busqueda sugerida