• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: XML beginner question (about special characters display)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: XML beginner question (about special characters display)


  • Subject: Re: XML beginner question (about special characters display)
  • From: JJ <email@hidden>
  • Date: Fri, 11 Oct 2002 14:36:32 +0200

> At 9:14 pm +0200 10/10/02, JJ wrote:
>
>> My goal is display correctly some special characters at browser (eg, html
>> entity &aacute;), but I don't know how to do it!
>>
>> I've seen that it works properly when it is written as UTF-8 (I can't
>> reproduce the characters at this list, but I'm talking about ASCII number
>> 135 or &aacute; translated to UTF-8). Then, it displays correctly as (ASCII
>> character 135) in my browser...
>>
>> Any magical routine to convert a string to UTF-8? I've been playing a little
>> with TEC osax, but I can't find the propper syntax to make it work right.
>> Also, can't I convert the special character to hex or different ascii
>> character to get it rigth displayed?
>>
>> Some samples with [&aacute; or ASCII character 135 or "accented a"] or
>> [&copy;] or [&ntilde;] would be appreciated...
>
> The perl script below will convert all Mac characters from #128 in
> $macstring to the proper html equivalents and open a browser window
> showing the result. I have not catered for "=%<>" etc.

I like perl solution.

> You can use perl to convert to UTF8, but you can also use TextEdit.
> Type the text in TextEdit, save the file with UTF-8 encoding and then
> run
>
> read file "path:to"saved:file"

I like "save as UTF-8" solution (from TextEdit or BBEdit or...).

> The syntax for TEC osax is
>
> set macstring to "some macroman text"
> set UTF8_ to TECConvertText macstring fromCode "macintosh" toCode "UTF-8"

Also, I love this TEC command.

Hmmmm.... What should I do? I'll try your three suggestions...

Cool Tx!!!

JJ

> To use the perl table,
>
> 1. Save the perl script below in your user directory as "mac2html.pl".
> 2. Save some Mac text there in an _ASCII_ text file named "mac.txt"
> ** Do not use TextEdit to save mac.txt unless you understand it **
> 3. Run the following AS script:
>
> do shell script "cd; perl mac2html.pl mac.txt"
>
> JD
>
> ______________________
>
> #!/usr/bin/perl
> $macstring = <ARGV> ;
> !$macstring and $macstring = "no files!" ;
> table();
> $f = "$ENV{HOME}/mac.html" ;
> open F, ">$f" or die $! ;
> print F "<html>" ;
> for ($macstring) {
> s~([\x80-\xFF])~$macToUnicode{$1}~g;
> print F;
> }
> `open $f` ;
> sub table {
> %macToUnicode = (
> "\x80"=>'&#xC4;',"\x81"=>'&#xC5;',"\x82"=>'&#xC7;',
> "\x83"=>'&#xC9;',"\x84"=>'&#xD1;',"\x85"=>'&#xD6;',
> "\x86"=>'&#xDC;',"\x87"=>'&#xE1;',"\x88"=>'&#xE0;',
> "\x89"=>'&#xE2;',"\x8A"=>'&#xE4;',"\x8B"=>'&#xE3;',
> "\x8C"=>'&#xE5;',"\x8D"=>'&#xE7;',"\x8E"=>'&#xE9;',
> "\x8F"=>'&#xE8;',"\x90"=>'&#xEA;',"\x91"=>'&#xEB;',
> "\x92"=>'&#xED;',"\x93"=>'&#xEC;',"\x94"=>'&#xEE;',
> "\x95"=>'&#xEF;',"\x96"=>'&#xF1;',"\x97"=>'&#xF3;',
> "\x98"=>'&#xF2;',"\x99"=>'&#xF4;',"\x9A"=>'&#xF6;',
> "\x9B"=>'&#xF5;',"\x9C"=>'&#xFA;',"\x9D"=>'&#xF9;',
> "\x9E"=>'&#xFB;',"\x9F"=>'&#xFC;',"\xA0"=>'&#x2020;',
> "\xA1"=>'&#xB0;',"\xA2"=>'&#xA2;',"\xA3"=>'&#xA3;',
> "\xA4"=>'&#xA7;',"\xA5"=>'&#x2022;',"\xA6"=>'&#xB6;',
> "\xA7"=>'&#xDF;',"\xA8"=>'&#xAE;',"\xA9"=>'&#xA9;',
> "\xAA"=>'&#x2122;',"\xAB"=>'&#xB4;',"\xAC"=>'&#xA8;',
> "\xAD"=>'&#x2260;',"\xAE"=>'&#xC6;',"\xAF"=>'&#xD8;',
> "\xB0"=>'&#x221E;',"\xB1"=>'&#xB1;',"\xB2"=>'&#x2264;',
> "\xB3"=>'&#x2265;',"\xB4"=>'&#xA5;',"\xB5"=>'&#xB5;',
> "\xB6"=>'&#x2202;',"\xB7"=>'&#x2211;',"\xB8"=>'&#x220F;',
> "\xB9"=>'&#x3C0;',"\xBA"=>'&#x222B;',"\xBB"=>'&#xAA;',
> "\xBC"=>'&#xBA;',"\xBD"=>'&#x3A9;',"\xBE"=>'&#xE6;',
> "\xBF"=>'&#xF8;',"\xC0"=>'&#xBF;',"\xC1"=>'&#xA1;',
> "\xC2"=>'&#xAC;',"\xC3"=>'&#x221A;',"\xC4"=>'&#x192;',
> "\xC5"=>'&#x2248;',"\xC6"=>'&#x2206;',"\xC7"=>'&#xAB;',
> "\xC8"=>'&#xBB;',"\xC9"=>'&#x2026;',"\xCA"=>'&#xA0;',
> "\xCB"=>'&#xC0;',"\xCC"=>'&#xC3;',"\xCD"=>'&#xD5;',
> "\xCE"=>'&#x152;',"\xCF"=>'&#x153;',"\xD0"=>'&#x2013;',
> "\xD1"=>'&#x2014;',"\xD2"=>'&#x201C;',"\xD3"=>'&#x201D;',
> "\xD4"=>'&#x2018;',"\xD5"=>'&#x2019;',"\xD6"=>'&#xF7;',
> "\xD7"=>'&#x25CA;',"\xD8"=>'&#xFF;',"\xD9"=>'&#x178;',
> "\xDA"=>'&#x2044;',"\xDB"=>'&#x20AC;',"\xDC"=>'&#x2039;',
> "\xDD"=>'&#x203A;',"\xDE"=>'&#xFB01;',"\xDF"=>'&#xFB02;',
> "\xE0"=>'&#x2021;',"\xE1"=>'&#xB7;',"\xE2"=>'&#x201A;',
> "\xE3"=>'&#x201E;',"\xE4"=>'&#x2030;',"\xE5"=>'&#xC2;',
> "\xE6"=>'&#xCA;',"\xE7"=>'&#xC1;',"\xE8"=>'&#xCB;',
> "\xE9"=>'&#xC8;',"\xEA"=>'&#xCD;',"\xEB"=>'&#xCE;',
> "\xEC"=>'&#xCF;',"\xED"=>'&#xCC;',"\xEE"=>'&#xD3;',
> "\xEF"=>'&#xD4;',"\xF0"=>'&#xF8FF;',"\xF1"=>'&#xD2;',
> "\xF2"=>'&#xDA;',"\xF3"=>'&#xDB;',"\xF4"=>'&#xD9;',
> "\xF5"=>'&#x131;',"\xF6"=>'&#x2C6;',"\xF7"=>'&#x2DC;',
> "\xF8"=>'&#xAF;',"\xF9"=>'&#x2D8;',"\xFA"=>'&#x2D9;',
> "\xFB"=>'&#x2DA;',"\xFC"=>'&#xB8;',"\xFD"=>'&#x2DD;',
> "\xFE"=>'&#x2DB;',"\xFF"=>'&#x2C7;'
> );
> }
> END_
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: XML beginner question (about special characters display)
      • From: John Delacour <email@hidden>
References: 
 >Re: XML beginner question (about special characters display) (From: John Delacour <email@hidden>)

  • Prev by Date: Re: custome icon on an applescript in OS X?
  • Next by Date: Re: "choose file name" Command
  • Previous by thread: Re: XML beginner question (about special characters display)
  • Next by thread: Re: XML beginner question (about special characters display)
  • Index(es):
    • Date
    • Thread