- 'mettre ca dans une module
- Friend Function QuotePrintNew(ByVal brute As String, ByVal charset As String) As String
- Dim resul As String = ""
- Dim deco As System.Text.Encoding
- Try
- deco = System.Text.Encoding.GetEncoding(charset)
- Catch ex As Exception
-
- deco = System.Text.Encoding.GetEncoding("iso-8859-1")
- End Try
-
- If deco.IsSingleByte Then 'ce tupe de codage se fait -il sur 1 ou 2 bytes
- resul = LookForSimple(deco, brute) 'codage sur un byte ex blabla=57 veut dire blabla & chr(57)
- 'mais le résultat dépend du type de codage
- Else
- resul = LookForDouble(deco, brute) 'codage sur 2 bytes blabla=57=87
- End If
-
-
-
- Return resul
- End Function
-
- Private Function LookForDouble(ByVal deco As System.Text.Encoding, ByVal brute As String) As String
- Dim i As Integer = 1
- Dim j As Integer = 0
- Dim temp As New System.Text.StringBuilder
- Dim ch As Char
- Dim table(1) As Byte
- Try
- Do While i <= brute.Length
- ch = Mid(brute, i, 1)
- If ch <> "=" Then
- temp.Append(ch)
- i += 1
- Else
- If Mid(brute, i + 1, 2) <> vbCrLf Then
- table(0) = CByte("&H" & Mid(brute, i + 1, 2))
- i += 3
- If Mid(brute, i, 1) = "=" Then
- If Mid(brute, i + 1, 2) <> vbCrLf Then
- table(1) = CByte("&H" & Mid(brute, i + 1, 2))
- i += 3
- Else
- table(1) = CByte("&H" & Mid(brute, i + 4, 2))
- i += 6
- End If
- End If
- temp.Append(deco.GetString(table))
- Else
- temp.Append(vbCrLf)
- i += 3
- End If
-
-
- End If
- Loop
- Catch ex As Exception
-
- End Try
- Return temp.ToString
- End Function
-
- Friend Function LookForSimple(ByVal deco As System.Text.Encoding, ByVal brute As String) As String
- Dim i As Integer = 1
- Dim temp As New System.Text.StringBuilder
- Dim ch As Char
- Dim table(0) As Byte
- Do While i <= brute.Length
- ch = Mid(brute, i, 1)
- If ch <> "=" Then
- temp.Append(ch)
- i += 1
- Else
- If Mid(brute, i + 1, 2) = vbCrLf Then
- temp.Append(vbCrLf)
- i += 3
- Else
- table(0) = CByte("&H" & Mid(brute, i + 1, 2))
- temp.Append(deco.GetString(table))
- i += 3
- End If
- End If
- Loop
- Return temp.ToString
- End Function
'mettre ca dans une module
Friend Function QuotePrintNew(ByVal brute As String, ByVal charset As String) As String
Dim resul As String = ""
Dim deco As System.Text.Encoding
Try
deco = System.Text.Encoding.GetEncoding(charset)
Catch ex As Exception
deco = System.Text.Encoding.GetEncoding("iso-8859-1")
End Try
If deco.IsSingleByte Then 'ce tupe de codage se fait -il sur 1 ou 2 bytes
resul = LookForSimple(deco, brute) 'codage sur un byte ex blabla=57 veut dire blabla & chr(57)
'mais le résultat dépend du type de codage
Else
resul = LookForDouble(deco, brute) 'codage sur 2 bytes blabla=57=87
End If
Return resul
End Function
Private Function LookForDouble(ByVal deco As System.Text.Encoding, ByVal brute As String) As String
Dim i As Integer = 1
Dim j As Integer = 0
Dim temp As New System.Text.StringBuilder
Dim ch As Char
Dim table(1) As Byte
Try
Do While i <= brute.Length
ch = Mid(brute, i, 1)
If ch <> "=" Then
temp.Append(ch)
i += 1
Else
If Mid(brute, i + 1, 2) <> vbCrLf Then
table(0) = CByte("&H" & Mid(brute, i + 1, 2))
i += 3
If Mid(brute, i, 1) = "=" Then
If Mid(brute, i + 1, 2) <> vbCrLf Then
table(1) = CByte("&H" & Mid(brute, i + 1, 2))
i += 3
Else
table(1) = CByte("&H" & Mid(brute, i + 4, 2))
i += 6
End If
End If
temp.Append(deco.GetString(table))
Else
temp.Append(vbCrLf)
i += 3
End If
End If
Loop
Catch ex As Exception
End Try
Return temp.ToString
End Function
Friend Function LookForSimple(ByVal deco As System.Text.Encoding, ByVal brute As String) As String
Dim i As Integer = 1
Dim temp As New System.Text.StringBuilder
Dim ch As Char
Dim table(0) As Byte
Do While i <= brute.Length
ch = Mid(brute, i, 1)
If ch <> "=" Then
temp.Append(ch)
i += 1
Else
If Mid(brute, i + 1, 2) = vbCrLf Then
temp.Append(vbCrLf)
i += 3
Else
table(0) = CByte("&H" & Mid(brute, i + 1, 2))
temp.Append(deco.GetString(table))
i += 3
End If
End If
Loop
Return temp.ToString
End Function