' 30/06/2027 MANMOG Version 3.0.7 Corrección CharConverter
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
<package >
|
<package >
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>tsl5</id>
|
<id>tsl5</id>
|
||||||
<version>3.0.6</version>
|
<version>3.0.7</version>
|
||||||
<authors>Tecnosis</authors>
|
<authors>Tecnosis</authors>
|
||||||
<owners>Tecnosis</owners>
|
<owners>Tecnosis</owners>
|
||||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||||
|
|||||||
@@ -31,12 +31,13 @@ Imports System.Runtime.InteropServices
|
|||||||
' mediante el asterisco ('*'), como se muestra a continuación:
|
' mediante el asterisco ('*'), como se muestra a continuación:
|
||||||
' <Assembly: AssemblyVersion("1.0.*")>
|
' <Assembly: AssemblyVersion("1.0.*")>
|
||||||
|
|
||||||
<Assembly: AssemblyVersion("3.0.6")>
|
<Assembly: AssemblyVersion("3.0.7")>
|
||||||
<Assembly: AssemblyFileVersion("3.0.6")>
|
<Assembly: AssemblyFileVersion("3.0.7")>
|
||||||
|
|
||||||
|
|
||||||
' Modificaciones:
|
' Modificaciones:
|
||||||
' ===============
|
' ===============
|
||||||
|
' 30/06/2027 MANMOG Version 3.0.7 Corrección CharConverter
|
||||||
' 26/06/2027 MANMOG Version 3.0.6 Se añade tsExcepcion
|
' 26/06/2027 MANMOG Version 3.0.6 Se añade tsExcepcion
|
||||||
' 03/06/2027 MANMOG Version 3.0.5 Correccion en tsNotificacionesClient
|
' 03/06/2027 MANMOG Version 3.0.5 Correccion en tsNotificacionesClient
|
||||||
' 14/05/2026 MANMOG Version 3.0.4 Actualización de .nuspec para que incluya dependencias externas
|
' 14/05/2026 MANMOG Version 3.0.4 Actualización de .nuspec para que incluya dependencias externas
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
Imports System.Windows.Forms
|
Imports System.Data
|
||||||
Imports System.Data
|
|
||||||
Imports System.Data.SqlClient
|
|
||||||
Imports MySql.Data.MySqlClient
|
|
||||||
Imports System.Data.OleDb
|
Imports System.Data.OleDb
|
||||||
Imports System.IO
|
Imports System.Data.SqlClient
|
||||||
'Imports ComponentAce.Compression.ZipForge
|
'Imports ComponentAce.Compression.ZipForge
|
||||||
'Imports ComponentAce.Compression.Archiver
|
'Imports ComponentAce.Compression.Archiver
|
||||||
Imports System.Environment
|
Imports System.Environment
|
||||||
|
Imports System.IO
|
||||||
|
Imports System.Text
|
||||||
|
Imports System.Windows.Forms
|
||||||
|
Imports MySql.Data.MySqlClient
|
||||||
|
|
||||||
'Imports UtilidadesTSL4net.clCharConv
|
'Imports UtilidadesTSL4net.clCharConv
|
||||||
|
|
||||||
@@ -3756,74 +3757,62 @@ Public Class clFuncionesGenericas
|
|||||||
|
|
||||||
|
|
||||||
End Function
|
End Function
|
||||||
Public Shared Sub CharConverter(ByVal jcOrigen As String, ByVal jcDestino As String, ByVal Fichero_Origen As String, Optional ByVal Fichero_Destino As String = "")
|
|
||||||
|
|
||||||
|
Public Shared Sub CharConverter(jcOrigen As String, jcDestino As String, Fichero_Origen As String, Optional Fichero_Destino As String = "")
|
||||||
Try
|
Try
|
||||||
Dim Temporal As String = Fichero_Origen & ".tmp"
|
' Seleccionamos las tablas de caracteres
|
||||||
Dim sBuffer As String
|
Dim origen() As Char = GetCharTable(jcOrigen)
|
||||||
Dim i, pos, fr, fw As Integer
|
Dim destino() As Char = GetCharTable(jcDestino)
|
||||||
Dim Size As Long = FileLen(Fichero_Origen)
|
|
||||||
Dim cAux(), cOrigen(), cDestino() As Char
|
If origen.Length <> destino.Length Then
|
||||||
'Inicializamos los juegos de caracteres origen y destino
|
Throw New Exception("Las tablas de conversión no tienen la misma longitud.")
|
||||||
Select Case jcOrigen.ToUpper
|
|
||||||
Case "WINDOWS"
|
|
||||||
cOrigen = WINDOWS
|
|
||||||
Case "ROMAN8"
|
|
||||||
cOrigen = ROMAN8
|
|
||||||
Case "ROMAN8SA"
|
|
||||||
cOrigen = ROMAN8SA
|
|
||||||
Case Else
|
|
||||||
' MsgBox("Juegos de caracteres origen erróneo o no soportado.")
|
|
||||||
' Exit Sub
|
|
||||||
Throw New Exception("Juego de caracteres origen erróneo.")
|
|
||||||
End Select
|
|
||||||
Select Case jcDestino.ToUpper
|
|
||||||
Case "WINDOWS"
|
|
||||||
cDestino = WINDOWS
|
|
||||||
Case "ROMAN8"
|
|
||||||
cDestino = ROMAN8
|
|
||||||
Case "ROMAN8SA"
|
|
||||||
cDestino = ROMAN8SA
|
|
||||||
Case Else
|
|
||||||
Throw New Exception("Juego de caracteres destino erróneo.")
|
|
||||||
'MsgBox("Juegos de caracteres destino erróneo o no soportado.")
|
|
||||||
'Exit Sub
|
|
||||||
End Select
|
|
||||||
'Abrimos Origen y Destino
|
|
||||||
fr = FreeFile()
|
|
||||||
fw = fr + 1
|
|
||||||
FileOpen(fr, Fichero_Origen, OpenMode.Input, OpenAccess.Read)
|
|
||||||
FileOpen(fw, Temporal, OpenMode.Output, OpenAccess.Write)
|
|
||||||
'Guardamos el contenido del fichero en un Buffer
|
|
||||||
sBuffer = InputString(fr, Size)
|
|
||||||
'Reemplazamos los caracteres especiales en Windows UTF8 por sus correspondientes en Roman8
|
|
||||||
cAux = sBuffer
|
|
||||||
For i = 0 To NumChar - 1
|
|
||||||
pos = 0
|
|
||||||
Do
|
|
||||||
pos = InStr(pos + 1, sBuffer, cOrigen(i), CompareMethod.Binary)
|
|
||||||
If pos > 0 Then
|
|
||||||
cAux(pos - 1) = cDestino(i)
|
|
||||||
End If
|
End If
|
||||||
Loop Until pos = 0
|
|
||||||
|
' Creamos diccionario de sustitución
|
||||||
|
Dim mapa As New Dictionary(Of Char, Char)
|
||||||
|
For i = 0 To origen.Length - 1
|
||||||
|
mapa(origen(i)) = destino(i)
|
||||||
Next
|
Next
|
||||||
sBuffer = cAux
|
|
||||||
Print(fw, sBuffer)
|
' Leemos el fichero como texto (UTF-8 por defecto)
|
||||||
'Cerramos los ficheros
|
Dim texto As String = File.ReadAllText(Fichero_Origen, Encoding.UTF8)
|
||||||
FileClose(fr, fw)
|
|
||||||
'Si el destino no viene especificado es que tomaremos el origen como destino
|
' Convertimos carácter por carácter
|
||||||
'y usaremos como destino para el proceso un fichero temporal
|
Dim sb As New StringBuilder(texto.Length)
|
||||||
If Fichero_Destino = "" Then
|
|
||||||
File.Copy(Temporal, Fichero_Origen, True)
|
For Each ch As Char In texto
|
||||||
|
If mapa.ContainsKey(ch) Then
|
||||||
|
sb.Append(mapa(ch))
|
||||||
Else
|
Else
|
||||||
File.Copy(Temporal, Fichero_Destino, True)
|
sb.Append(ch)
|
||||||
End If
|
End If
|
||||||
'Borramos el fichero temporal
|
Next
|
||||||
File.Delete(Temporal)
|
|
||||||
|
' Determinar destino
|
||||||
|
Dim rutaDestino As String = If(Fichero_Destino = "", Fichero_Origen, Fichero_Destino)
|
||||||
|
|
||||||
|
' Guardar resultado
|
||||||
|
File.WriteAllText(rutaDestino, sb.ToString(), Encoding.UTF8)
|
||||||
|
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
'MsgBox(ex.Message, , "Error")
|
Throw New Exception("Error en CharConverter: " & ex.Message)
|
||||||
Throw New Exception(ex.Message)
|
|
||||||
End Try
|
End Try
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Private Shared Function GetCharTable(nombre As String) As Char()
|
||||||
|
Select Case nombre.ToUpper()
|
||||||
|
Case "WINDOWS"
|
||||||
|
Return WINDOWS
|
||||||
|
Case "ROMAN8"
|
||||||
|
Return ROMAN8
|
||||||
|
Case "ROMAN8SA"
|
||||||
|
Return ROMAN8SA
|
||||||
|
Case Else
|
||||||
|
Throw New Exception("Juego de caracteres no soportado: " & nombre)
|
||||||
|
End Select
|
||||||
|
End Function
|
||||||
|
|
||||||
Public Shared Function LeeRegistrosSQLSQLServer(ByVal Conexion As SqlConnection, ByVal Clausula_SQL As String, Optional ByVal Sin_Errores As Boolean = True, Optional ByVal NombreDataset As String = "DATASET", Optional ByVal NombreTabla As String = "TABLA") As DataTable
|
Public Shared Function LeeRegistrosSQLSQLServer(ByVal Conexion As SqlConnection, ByVal Clausula_SQL As String, Optional ByVal Sin_Errores As Boolean = True, Optional ByVal NombreDataset As String = "DATASET", Optional ByVal NombreTabla As String = "TABLA") As DataTable
|
||||||
LeeRegistrosSQLSQLServer = Nothing
|
LeeRegistrosSQLSQLServer = Nothing
|
||||||
Try
|
Try
|
||||||
|
|||||||
Reference in New Issue
Block a user