Konwerter tekstu - program do konwersji tekstu między stronami kodowymi - kod źródłowy

Attribute VB_Name = "Module2"

Public Function CnV(Lancuch As String, co As Variant, na_co As Variant) As String
On Error Resume Next
Dim CP_1250 As Variant
Dim ISO_8859_2 As Variant
Dim Windows_EE As Variant
Dim IBM_CP852 As Variant
Dim Mazovia As Variant
Dim CSK As Variant
Dim Cyfromatv As Variant
Dim DHN As Variant
Dim IINTE_ISIS As Variant
Dim IEA_Swierk As Variant
Dim Logic As Variant
Dim Microvex As Variant
Dim Ventura As Variant
Dim ELWRO_Junior As Variant
Dim Mac As Variant
Dim AmigaPL As Variant
Dim TeXPL As Variant
Dim Atari_Calamus As Variant
Dim CorelDraw As Variant
Dim ATM As Variant


Dim intLicznik, i As Integer
Dim strLiterka, strText As String
strText = Lancuch


CP_1250 = Array("Ľ", "Ć", "Ę", "Ł", "Ń", "Ó", "Œ", "", "Ż", "š", "ć", "ę", "ł", "ń", "ó", "œ", "Ÿ", "ż")
ISO_8859_2 = Array(Chr(161), Chr(198), Chr(202), Chr(163), Chr(209), Chr(211), Chr(166), Chr(172), Chr(175), Chr(177), Chr(230), Chr(234), Chr(179), Chr(241), Chr(243), Chr(182), Chr(188), Chr(191))
Windows_EE = Array(Chr(165), Chr(198), Chr(202), Chr(163), Chr(209), Chr(211), Chr(140), Chr(143), Chr(175), Chr(185), Chr(230), Chr(234), Chr(179), Chr(241), Chr(243), Chr(156), Chr(159), Chr(191))
IBM_CP852 = Array(Chr(164), Chr(143), Chr(168), Chr(157), Chr(227), Chr(224), Chr(151), Chr(141), Chr(189), Chr(165), Chr(134), Chr(169), Chr(136), Chr(228), Chr(162), Chr(152), Chr(171), Chr(190))
Mazovia = Array(Chr(143), Chr(149), Chr(144), Chr(156), Chr(165), Chr(163), Chr(152), Chr(160), Chr(161), Chr(134), Chr(141), Chr(145), Chr(146), Chr(164), Chr(162), Chr(158), Chr(166), Chr(167))
CSK = Array(Chr(128), Chr(129), Chr(130), Chr(131), Chr(132), Chr(133), Chr(134), Chr(136), Chr(135), Chr(160), Chr(161), Chr(162), Chr(163), Chr(164), Chr(165), Chr(166), Chr(168), Chr(167))
Cyfromat = Array(Chr(128), Chr(129), Chr(130), Chr(131), Chr(132), Chr(133), Chr(134), Chr(136), Chr(135), Chr(144), Chr(145), Chr(146), Chr(147), Chr(148), Chr(149), Chr(150), Chr(152), Chr(151))
DHN = Array(Chr(128), Chr(129), Chr(130), Chr(131), Chr(132), Chr(133), Chr(134), Chr(136), Chr(135), Chr(137), Chr(138), Chr(139), Chr(140), Chr(141), Chr(142), Chr(143), Chr(145), Chr(144))
IINTE_ISIS = Array(Chr(128), Chr(129), Chr(130), Chr(131), Chr(132), Chr(133), Chr(134), Chr(135), Chr(136), Chr(144), Chr(145), Chr(146), Chr(147), Chr(148), Chr(149), Chr(150), Chr(151), Chr(152))
IEA_Swierk = Array(Chr(143), Chr(128), Chr(144), Chr(156), Chr(165), Chr(153), Chr(235), Chr(157), Chr(146), Chr(160), Chr(155), Chr(130), Chr(159), Chr(164), Chr(162), Chr(135), Chr(168), Chr(145))
Logic = Array(Chr(128), Chr(129), Chr(130), Chr(131), Chr(132), Chr(133), Chr(134), Chr(135), Chr(136), Chr(137), Chr(138), Chr(139), Chr(140), Chr(141), Chr(142), Chr(143), Chr(144), Chr(145))
Microvex = Array(Chr(143), Chr(128), Chr(144), Chr(156), Chr(165), Chr(147), Chr(152), Chr(157), Chr(146), Chr(160), Chr(155), Chr(130), Chr(159), Chr(164), Chr(162), Chr(135), Chr(168), Chr(145))
Ventura = Array(Chr(151), Chr(153), Chr(165), Chr(166), Chr(146), Chr(143), Chr(142), Chr(144), Chr(128), Chr(150), Chr(148), Chr(164), Chr(167), Chr(145), Chr(162), Chr(132), Chr(130), Chr(135))
ELWRO_Junior = Array(Chr(193), Chr(195), Chr(197), Chr(204), Chr(206), Chr(207), Chr(211), Chr(218), Chr(217), Chr(225), Chr(227), Chr(229), Chr(236), Chr(238), Chr(239), Chr(243), Chr(250), Chr(249))
Mac = Array(Chr(132), Chr(140), Chr(162), Chr(252), Chr(193), Chr(238), Chr(229), Chr(143), Chr(251), Chr(136), Chr(141), Chr(171), Chr(184), Chr(196), Chr(151), Chr(230), Chr(144), Chr(253))
AmigaPL = Array(Chr(194), Chr(202), Chr(203), Chr(206), Chr(207), Chr(211), Chr(212), Chr(218), Chr(219), Chr(226), Chr(234), Chr(235), Chr(238), Chr(239), Chr(243), Chr(244), Chr(250), Chr(251))
TeXPL = Array(Chr(129), Chr(130), Chr(134), Chr(138), Chr(139), Chr(211), Chr(145), Chr(153), Chr(155), Chr(161), Chr(162), Chr(166), Chr(170), Chr(171), Chr(243), Chr(177), Chr(185), Chr(187))
Atari_Calamus = Array(Chr(193), Chr(194), Chr(195), Chr(196), Chr(197), Chr(198), Chr(199), Chr(200), Chr(201), Chr(209), Chr(210), Chr(211), Chr(212), Chr(213), Chr(214), Chr(215), Chr(216), Chr(217))
CorelDraw = Array(Chr(197), Chr(242), Chr(201), Chr(163), Chr(209), Chr(211), Chr(255), Chr(225), Chr(237), Chr(229), Chr(236), Chr(230), Chr(198), Chr(241), Chr(243), Chr(165), Chr(170), Chr(186))
ATM = Array(Chr(196), Chr(199), Chr(203), Chr(208), Chr(209), Chr(211), Chr(214), Chr(218), Chr(220), Chr(228), Chr(231), Chr(235), Chr(240), Chr(241), Chr(243), Chr(246), Chr(250), Chr(252))

Select Case co
    Case "ISO_8859_2"
        co = ISO_8859_2
    Case "Windows_EE"
        co = Windows_EE
    Case "IBM_CP852"
        co = IBM_CP852
    Case "Mazovia"
        co = Mazovia
    Case "CSK"
        co = CSK
    Case "Cyfromatv"
        co = Cyfromatv
    Case "DHN"
        co = DHN
    Case "IINTE_ISIS"
        co = IINTE_ISIS
    Case "IEA_Swierk"
        co = IEA_Swierk
    Case "Logic"
        co = Logic
    Case "Microvex"
        co = Microvex
    Case "Ventura"
        co = Ventura
    Case "ELWRO_Junior"
        co = ELWRO_Junior
    Case "Mac"
        co = Mac
    Case "AmigaPL"
        co = AmigaPL
    Case "TeXPL"
        co = TeXPL
    Case "Atari_Calamus"
        co = Atari_Calamus
    Case "CorelDraw"
        co = CorelDraw
    Case "ATM"
        co = ATM
    Case "CP_1250"
        co = CP_1250
        
End Select


Select Case na_co
    Case "ISO_8859_2"
        na_co = ISO_8859_2
    Case "Windows_EE"
        na_co = Windows_EE
    Case "IBM_CP852"
        na_co = IBM_CP852
    Case "Mazovia"
        na_co = Mazovia
    Case "CSK"
        na_co = CSK
    Case "Cyfromatv"
        na_co = Cyfromatv
    Case "DHN"
        na_co = DHN
    Case "IINTE_ISIS"
        na_co = IINTE_ISIS
    Case "IEA_Swierk"
        na_co = IEA_Swierk
    Case "Logic"
        na_co = Logic
    Case "Microvex"
        na_co = Microvex
    Case "Ventura"
        na_co = Ventura
    Case "ELWRO_Junior"
        na_co = ELWRO_Junior
    Case "Mac"
        na_co = Mac
    Case "AmigaPL"
        na_co = AmigaPL
    Case "TeXPL"
        na_co = TeXPL
    Case "Atari_Calamus"
        na_co = Atari_Calamus
    Case "CorelDraw"
        na_co = CorelDraw
    Case "ATM"
        na_co = ATM
    Case "CP_1250"
        na_co = CP_1250
        
End Select
licznik = 0
 strText = Lancuch
 For intLicznik = 1 To Len(strText)
      strLiterka = Mid(strText, intLicznik, 1)
      For i = 0 To UBound(ISO_8859_2)
            If StrComp(strLiterka, co(i), 0) = 0 Then
                Mid(strText, intLicznik, 1) = na_co(i)
                licznik = licznik + 1
            End If
      Next i
 Next intLicznik



CnV = strText

End Function