Windows to Mac Text Translator

Dear all,

I am working with Delphi2009.

I want to create a translator that translates text files between simple ANSI encoding and the MAC equivalent.  Problem seems to exist with greek characters.

Thought of doing a character map with the changed characters and check for each character in my text indivicually if that character exists in my character map array to replace it, but it takes much time.

I attach a file with the two equivalents.  Need to find out how to utilize character mapping so I produce one from the other and vise versa.

Any help would be appreciated
Ioannis AnifantakisSoftware EngineerAsked:
Who is Participating?
Okay, let's back up a bit.
Problem seems to exist with greek characters.
Can you describe what the problem is?  I was assuming that you were getting display errors but that may not be the case.
If you want the fastest way to translate from one character to another, put the two sets of characters in sepearate strings in correstponding order.  Then you can use the POS function to find the position in the first string and then select the character from that position in the second string in order to translate.  It also gives you the ability to go either direction.
Try this link for more on the subject . . . it seems to be very thorough.
Check the following for some guidance: 
Ioannis AnifantakisSoftware EngineerAuthor Commented:
Sorry it doesn't help.

I have the conversion using an array of a record

// this is the delphi RECORD
type converter=RECORD
    mac,win: char;

//this is the array of "converter" RECORDS
conv_table: array[1..67] of converter;

// this is the method that holds the mapping
procedure TForm1.initConverter;
    conv_table[01].win:='a'; conv_table[01].mac:='a';
    conv_table[02].win:='ß'; conv_table[02].mac:='ß';
    conv_table[03].win:='¿'; conv_table[03].mac:='¿';
    conv_table[04].win:='d'; conv_table[04].mac:='d';
    conv_table[05].win:='e'; conv_table[05].mac:='e';
    conv_table[06].win:='¿'; conv_table[06].mac:='¿';
    conv_table[07].win:='¿'; conv_table[07].mac:='¿';
    conv_table[08].win:='¿'; conv_table[08].mac:='¿';
    conv_table[09].win:='¿'; conv_table[09].mac:='¿';
    conv_table[10].win:='¿'; conv_table[10].mac:='¿';
    conv_table[11].win:='¿'; conv_table[11].mac:='µ';
    conv_table[12].win:='µ'; conv_table[12].mac:='¿';
    conv_table[13].win:='¿'; conv_table[13].mac:='¿';
    conv_table[14].win:='¿'; conv_table[14].mac:='¿';
    conv_table[15].win:='¿'; conv_table[15].mac:='¿';
    conv_table[16].win:='p'; conv_table[16].mac:='p';
    conv_table[17].win:='¿'; conv_table[17].mac:='¿';
    conv_table[18].win:='s'; conv_table[18].mac:='s';
    conv_table[19].win:='t'; conv_table[19].mac:='t';
    conv_table[20].win:='¿'; conv_table[20].mac:='¿';
    conv_table[21].win:='f'; conv_table[21].mac:='¿';
    conv_table[22].win:='¿'; conv_table[22].mac:='¿';
    conv_table[23].win:='¿'; conv_table[23].mac:='¿';
    conv_table[24].win:='¿'; conv_table[24].mac:='f';

    conv_table[25].win:='¿'; conv_table[25].mac:='°';
    conv_table[26].win:='¿'; conv_table[26].mac:='µ';
    conv_table[27].win:='G'; conv_table[27].mac:='¿';
    conv_table[28].win:='¿'; conv_table[28].mac:='¿';
    conv_table[29].win:='¿'; conv_table[29].mac:='¶';
    conv_table[30].win:='¿'; conv_table[30].mac:='·';
    conv_table[31].win:='¿'; conv_table[31].mac:='¿';
    conv_table[32].win:='T'; conv_table[32].mac:='£';
    conv_table[33].win:='¿'; conv_table[33].mac:='¿';
    conv_table[34].win:='¿'; conv_table[34].mac:='¿';
    conv_table[35].win:='¿'; conv_table[35].mac:='¤';
    conv_table[36].win:='¿'; conv_table[36].mac:='»';
    conv_table[37].win:='¿'; conv_table[37].mac:='¿';
    conv_table[38].win:='¿'; conv_table[38].mac:='¥';
    conv_table[39].win:='¿'; conv_table[39].mac:='G';
    conv_table[40].win:='¿'; conv_table[40].mac:='¦';
    conv_table[41].win:='¿'; conv_table[41].mac:='¿';
    conv_table[42].win:='S'; conv_table[42].mac:='¿';
    conv_table[43].win:='¿'; conv_table[43].mac:='¿';
    conv_table[44].win:='¿'; conv_table[44].mac:='¿';
    conv_table[45].win:='F'; conv_table[45].mac:='¿';
    conv_table[46].win:='¿'; conv_table[46].mac:='¿';
    conv_table[47].win:='¿'; conv_table[47].mac:='¿';
    conv_table[48].win:='O'; conv_table[48].mac:='¿';

    conv_table[49].win:='¿'; conv_table[49].mac:='¿';

    conv_table[50].win:='¿'; conv_table[50].mac:='¿';
    conv_table[51].win:='¿'; conv_table[51].mac:='¿';
    conv_table[52].win:='¿'; conv_table[52].mac:='¿';
    conv_table[53].win:='¿'; conv_table[53].mac:='¿';
    conv_table[54].win:='¿'; conv_table[54].mac:='¿';
    conv_table[55].win:='¿'; conv_table[55].mac:='¿';
    conv_table[56].win:='¿'; conv_table[56].mac:='¿';

    conv_table[57].win:='¿'; conv_table[57].mac:='¿';
    conv_table[58].win:='¿'; conv_table[58].mac:='¿';
    conv_table[59].win:='¿'; conv_table[59].mac:='¿';
    conv_table[60].win:='¿'; conv_table[60].mac:='¿';
    conv_table[61].win:='¿'; conv_table[61].mac:='¿';
    conv_table[62].win:='¿'; conv_table[62].mac:='¿';

    conv_table[62].win:='¿'; conv_table[62].mac:='¿';
    conv_table[63].win:='¿'; conv_table[63].mac:='¿';
    conv_table[64].win:='¿'; conv_table[64].mac:='¿';
    conv_table[65].win:='¿'; conv_table[65].mac:='¿';

    conv_table[66].win:='¿'; conv_table[66].mac:='«';
    conv_table[67].win:='¿'; conv_table[67].mac:='½';

Open in new window

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Ioannis AnifantakisSoftware EngineerAuthor Commented:
Ok, I followed a technique close to that.

I made use of hashtables for the translation.  More specifically I made few changes to a hashtable class provided by Niclas Svan, by adding an extra constructor where you can specify if you want CaseSensitive keys and values so that you can distinguish between upper and lower case letters when you search, and I also provided a backwards check by adding "function GetKey(const strVal : string): string;".

These to the actual unit being used.  On top of that I added another unit of mine that does the transform by allowing the user to either create an object and work though it, or by making static calls.

Check it out before I deliver you the points
Ioannis AnifantakisSoftware EngineerAuthor Commented:
To also explain you what I wanted, from the initial post of mine I had two files.

The windows file created and saved.  And then the Macintosh equivalent so it can be read by macintosh machines.  Therefore I wanted to get a fast algorithm to translate characters found in WIN-TEXT to the equivalent MAC-TEXT.

For the set of the characters concerned that seemed to be wrong, I provided my own solution on my above text.

However I will award you the points, because the techique followed is somewhat close to the way you instructed me on your second reply :)
Thank you for your generosity and I am glad I was of (at least some ;-) assistance.
I have played in the same arena in the past (albeit not involving Mac's ;-).  I know how frustrating things can get when you are translating characters.
Good luck and have fun! ;_)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.