Windows to Mac Text Translator

Posted on 2010-09-14
Last Modified: 2013-11-23
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
Question by:ioannisa
  • 3
  • 3
LVL 22

Expert Comment

ID: 33675239
Check the following for some guidance: 

Author Comment

ID: 33680888
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

LVL 22

Accepted Solution

8080_Diver earned 500 total points
ID: 33684249
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.
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.


Author Comment

ID: 33684330
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

Author Comment

ID: 33684363
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 :)
LVL 22

Expert Comment

ID: 33686768
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! ;_)

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now