' Greek to Greek character conversion ' ' The following Visual Basic functions can be included in any project that needs such conversion; ' for example, it can be entered as macro code to translate a Word document or an Excel worksheet (that ' was the motivator for writing them in the first place) ' ' Usage: ' Call function Translate passing it as first argument the string to be converted and as second argument ' the translation table. The translation tables are returned by their nameshake functions. The following ' conversions are currently supported: ' ISO-8859-7 <-> Windows 1253 ' ISO-8859-7 <-> MS-DOS CP437 ' Windows 1253 <-> MS-DOS CP437 ' ' Example: ' Translate(InText, CP1253_To_CP437_Table()) ' will convert InText from MS-Windows greek encoding to MS-DOS greek encoding ' ' Credits: ' The general design pattern (interface, function names, etc.) comes from an article in Microsoft's Knowledge Base that ' can be found at http://support.microsoft.com/default.aspx?scid=kb;EN-US;q216399. The article concerns EBCDIC to ASCII conversion. ' The actual translation tables were created from the perl gr2gr.pl utility, written by A. Haritsis; specifically, the ' the translation tables concerning the ISO encoding were copied verbatim; minor modifications led to other translation ' tables. ' ' Copyright (C) 2002 P. Louridas ' ' This program is free software; you can redistribute it and/or ' modify it under the terms of the GNU General Public License ' as published by the Free Software Foundation; either version 2 ' of the License, or (at your option) any later version. ' ' This program is distributed in the hope that it will be useful, ' but WITHOUT ANY WARRANTY; without even the implied warranty of ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ' GNU General Public License for more details. ' ' You should have received a copy of the GNU General Public License ' along with this program; if not, write to the Free Software ' Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ' Option Explicit Function Translate(ByVal InText As String, xlatTable As String) As String ' ' Uses a translation table to map InText from one character set to another. ' Dim Temp As String, I As Long, Pos As Long, SepPos As Long Temp = Space(Len(InText)) SepPos = InStr(xlatTable, "/") For I = 1 To Len(InText) Pos = InStr(xlatTable, Mid(InText, I, 1)) If Pos <> 0 Then Mid(Temp, I, 1) = Mid(xlatTable, SepPos + Pos, 1) Else Mid(Temp, I, 1) = Mid(InText, I, 1) End If Next I Translate = Temp End Function Function CP1253_To_ISO_Table() As String ' ' Returns the following table as a string for use by the Translate ' function to translate a CP1253 string to an ISO-8859-7 string. ' CP1253_To_ISO_Table = "¢/¶" End Function Function ISO_To_CP1253_Table() As String ' ' Returns the following table as a string for use by the Translate ' function to translate an ISO-8859-7 to a CP1253 string. ' ISO_To_CP1253_Table = "¶/¢" End Function Function CP437_To_ISO_Table() As String ' ' Returns the following table as a string for use by the Translate ' function to traslate a CP437 string to an ISO-8859-7 string. ' CP437_To_ISO_Table = "?™?›???? ¡¢£¤¥¦§¨©?«¬­®¯àáâãåäÀæçèàé€?‚ƒ„…†‡?‰?‹?????‘’“”•–—¶¸¹ºÚ¼¾Û¿/áâãäåæçèéêëìíîïðñóòôõö÷øùÜÝÞßúÀüýûàþÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÓÔÕÖ×ØÙ¶¸¹ºÚ¼¾Û¿" End Function Function ISO_To_CP437_Table() As String ' ' Returns the following table as a string for use by the Translate ' function to traslate an ISO-8859-7 string to a CP437 string. ' ISO_To_CP437_Table = "áâãäåæçèéêëìíîïðñóòôõö÷øùÜÝÞßúÀüýûàþÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÓÔÕÖ×ØÙ¶¸¹ºÚ¼¾Û¿/?™?›???? ¡¢£¤¥¦§¨©?«¬­®¯àáâãåääæçèèé€?‚ƒ„…†‡?‰?‹?????‘’“”•–—€„†???““—" End Function Function CP1253_To_CP437_Table() As String ' ' Returns the following table as a string for use by the Translate ' function to traslate a CP1253 string to a CP437 string. ' CP1253_To_CP437_Table = "áâãäåæçèéêëìíîïðñóòôõö÷øùÜÝÞßúÀüýûàþÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÓÔÕÖ×ØÙ¶¢¸¹ºÚ¼¾Û¿/?™?›???? ¡¢£¤¥¦§¨©?«¬­®¯àáâãåääæçèèé€?‚ƒ„…†‡?‰?‹?????‘’“”•–—€€„†???““—" End Function Function CP437_To_CP1253_Table() As String ' ' Returns the following table as a string for use by the Translate ' function to traslate a CP437 string to a CP1253 string. ' CP437_To_CP1253_Table = "?™?›???? ¡¢£¤¥¦§¨©?«¬­®¯àáâãåäÀæçèàé€?‚ƒ„…†‡?‰?‹?????‘’“”•–—¶¸¹ºÚ¼¾Û¿/áâãäåæçèéêëìíîïðñóòôõö÷øùÜÝÞßúÀüýûàþÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÓÔÕÖ×ØÙ¢¸¹ºÚ¼¾Û¿" End Function