Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library > Formatting Text

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old August 22nd, 2008, 08:44 AM
Admin's Avatar
Admin Admin is offline
Administrator
 
Join Date: Oct 2007
Posts: 331
Default Special Characters Included in Both MacRoman Encoding and Latin-1 Encoding

Original post removed to reduce confusion. Please follow Dan's post below.
__________________
Forum Administrator
PTI Marketing Technologies, Inc.

Last edited by Admin; September 24th, 2008 at 01:08 PM..
Reply With Quote
  #2  
Old September 24th, 2008, 01:03 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,327
Exclamation Re: Special Characters Included in Both MacRoman Encoding and Latin-1 Encoding

This is a corrected version of the post above, in which all of the entities got converted to their actual character values by the "helpful" vBulletin forum software. (This is ironic, considering that the whole point of the post is to explain how to use the entities themselves in JavaScript.)


Please use [code] and [/code] tag pairs when including code samples to avoid this problem. You may also need to use [noparse] and [/noparse] tag pairs to ensure that markup is shown literally in the forum. (Note that for the numeric entities such as ¼ the only way I could get vBulletin to show the entity literally instead of parsing it and showing the ¼ character was to "fake it out" by modifying the size or colors of some, not all, of the characters in the entity itself.)

Don't be afraid to use the "Preview Post" button or edit your post to make sure the code looks right. Thanks!

CORRECTED POST FOLLOWS

Since almost all glyphs used in Western languages are included in both the Latin-1 encoding character set used on Windows, and in MacRoman on Mac, so FusionPro has no problem with them. However, in the great Tower of Babel that is character encoding, a few characters that are standard in Latin-1 (aka ISO-8859-1) fell through the cracks and did not get included in MacRoman encoding, including the fractional characters in question. The full list of such characters can be found here:
http://www.alanwood.net/demos/charsetdiffs.html#d
and here:
http://home.earthlink.net/~bobbau/platforms/specialchars/#non-mac

And there's some historical background here:
http://ppewww.ph.gla.ac.uk/~flavell/iso8859/iso8859-mac.html
and here:
http://meta.wikimedia.org/wiki/Help_talk:Special_characters

FusionPro does not include the fractional entities ("¼", "½", and "¾") in its entity.mac.def file, and you can't use numeric entities (such as "¼") either, because those characters are simply not mapped to any 8-bit ASCII values in Mac Roman encoding.

The named entities will still work on Windows, however, and since you're doing the actual composition there, the real issue is how to represent and specify these characters on Mac.

My recommendation is to use JavaScript to create rules that return entities designating the actual glyphs on Windows and substitute representations on Mac. You still won't be able to type them directly into the Text Editor, but you'll get the actual character symbol in your composed output on Windows, and an approximate representation on Mac.

For instance, you could create a rule called "Fraction 1/4" like so:
Code:
 
if (FusionPro.isMac)
  return "<superscript>1</superscript>/<subscript>4</subscript>";
//else
  return "&frac14;";
(Make sure to check the "Treat returned strings as tagged text" checkbox
in the Rule Editor.)
The exact representation obviously depends on your superscript and subscript settings in the Paragraph Globals dialog on Mac. And superscript may affect your auto-leading. If you don't want to worry about this, you can simply return the string "1/4" on Mac.

If you can find a symbol font that shows the character in MacRoman encoding, you can also do a simple font substitution with a numeric entity. I haven't found such a font, but if you do, you could do something like this instead:
Code:
if (FusionPro.isMac)
  return "<font name=\"My Special Font\">&#188;</font>";
//else
  return "&frac14;";
The other caveat here is that this might not work with some older Mac fonts which do not contain the correct mappings under Latin-1, if they are brought over to Windows with Assets.dat. However, most modern fonts should have no problem. Even in the worst-case scenario, if the font does not contain the character, you can just switch the font on Windows, like so:
Code:
 
if (FusionPro.isMac)
  return "<superscript>1</superscript>/<subscript>4</subscript>";
//else
  return "<font name=\"Arial\">&frac14;</font>";
If necessary, you could use a numeric entity on Windows as well. But I doubt you will have to do that.
Here's a generalized solution:

Code:
  function FractionCharacter(fraction)
  {
    switch (fraction)
    {
      case 1/4:
      case "1/4":
      case "14":
      case "&frac14;":
      {
        if (FusionPro.isMac)
          return "<superscript>1</superscript>/<subscript>4</subscript>";
        //else
          return "&frac14;";
      }
      case 1/2:
      case "1/2":
      case "12":
      case "&frac12;":
      {
        if (FusionPro.isMac)
          return "<superscript>1</superscript>/<subscript>2</subscript>";
        //else
          return "&frac12;";
      }
      case 3/4:
      case "3/4":
      case "34":
      case "&frac34;":
      {
        if (FusionPro.isMac)
          return "<superscript>3</superscript>/<subscript>4</subscript>";
        //else
          return "&frac34;";
      }
    }
    ReportError("No glyph for fraction " + fraction);
    return "";
  }

Using this function, you can create rules with names like "Fraction 1/4", and insert the corresponding variables in the Text Editor on either platform. If another solution becomes available in the future, or you want to try something different, you will only have to modify that single function.
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #3  
Old June 28th, 2017, 07:44 AM
gdellaiera gdellaiera is offline
Regular Contributor
 
Join Date: Nov 2016
Posts: 78
Default Re: Special Characters Included in Both MacRoman Encoding and Latin-1 Encoding

I have been trying to add a square bullet using a script in front of a field using;
if (Field(“Certification 1”) == ""){
return "";
}else{
return "<p>◻" + Field(“Certification 1”) + "</p>";
}*

Is this format not supported? I'm still learning javascript & I may be a little lost with this.
Reply With Quote
  #4  
Old June 28th, 2017, 08:38 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,327
Default Re: Special Characters Included in Both MacRoman Encoding and Latin-1 Encoding

Quote:
Originally Posted by gdellaiera View Post
I have been trying to add a square bullet using a script in front of a field using;
if (Field(“Certification 1”) == ""){
return "";
}else{
return "<p>◻" + Field(“Certification 1”) + "</p>";
}*

Is this format not supported? I'm still learning javascript & I may be a little lost with this.
Your question is not directly relevant to platform-specific encoding. Please start a new thread.
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 05:13 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.