?
Solved

Windows to Mac Text Translator

Posted on 2010-09-14
6
Medium Priority
?
471 Views
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
characters.zip
0
Comment
Question by:ioannisa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 22

Expert Comment

by:8080_Diver
ID: 33675239
Check the following for some guidance:
http://weblogs.asp.net/ahoffman/archive/2004/01/19/60094.aspx 
0
 
LVL 6

Author Comment

by:ioannisa
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;
end;

//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;
begin
    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:='½';
end;

Open in new window

0
 
LVL 22

Accepted Solution

by:
8080_Diver earned 2000 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.
0
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
LVL 6

Author Comment

by:ioannisa
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
translator.zip
0
 
LVL 6

Author Comment

by:ioannisa
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 :)
0
 
LVL 22

Expert Comment

by:8080_Diver
ID: 33686768
joannisa,
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! ;_)
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

741 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