Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

writing smart quotes into a text file

Featured Replies

I'm trying to build a quick "simple" database that will allow me to write several XML files based on a template. The template has "smart quotes" that need to be preserved, and so far NOT escaping them has led to AppleScript errors (used to write the XML back out to a file) but escaping them actually puts "regular" quotes into the text file.

I tried replacing the smart quotes with decimal numeric character references but that doesn't work for the application that needs to parse the XML I'm writing.

Anyone have a suggestion?

Have you tried something like:

character id 8220 & "abc" & character id 8221

BTW, why aren't you using Filemaker's XML exporting?

  • Author

I assumed that FileMaker's XML exporting makes a FileMaker XML file, is that true? If so that's no useful to me, I am making a file that isn't FileMaker XML.

I found out that the application that I'm writing these files for needs the smart quotes to actually be in the XML file, I can't use entities. I was told, however, that maybe I could "output a raw byte in the text stream", how would I do that?

BTW, here is an example of what I'm doing, my goal is to put smart quotes around the replaced "song title" but do it in such a way that the calculated AppleScript script step doesn't choke. My example takes an XML template and uses a calculation to replace some tokens with text entered into a couple text fields.

XML exporting makes a FileMaker XML file, is that true?

Yes and no. The default format is one of Filemaker's own XML grammars, but Filemaker has a built in XSLT engine that can transform the exported file using a custom stylesheet.

the application that I'm writing these files for needs the smart quotes to actually be in the XML file

I am looking at your example, and the only quotes I see are those surrounding the attribute values of the styleRun element. These quotes MUST be regular quotes (single or double), or the document will NOT be a valid XML document.

You could still make those quotes smart, by transforming the export to a text file (instead of to XML). But I would suggest you check this requirement again, because it is a VERY irregular one.

  • Author

Sorry about that. The example I put out doesn't have the smart quotes, because I wanted to put up the example in a "working" state.

To see where I want the smart quotes to go change the calculation in the field definition for CalculatedMotionProject to:

Substitute ( Substitute ( Substitute ( Substitute ( MotionTemplateText ; "SONGTITLECHARCOUNT" ; SongTitleCharCount ) ; "PERFORMINGGROUPCHARCOUNT" ; PerformingGroupCharCount ) ; "SONGTITLE" ; "“" & SongTitle &

 "”" ) ; "PERFORMINGGROUP" ; PerformingGroup )




Now run the script and AppleScript fails because now the calculated AppleScript is busted due to the addition of the quote.



Next escape the smart quotes by again changing the calculation definition, this time to:




Substitute ( Substitute ( Substitute ( Substitute ( MotionTemplateText ; "SONGTITLECHARCOUNT" ; SongTitleCharCount ) ; "PERFORMINGGROUPCHARCOUNT" ; PerformingGroupCharCount ) ; "SONGTITLE" ; "“" & SongTitle &

 "”" ) ; "PERFORMINGGROUP" ; PerformingGroup )

Now my "Run!" script works and a file is written to the Desktop. But view that file in a text editor and you'll see that my smart quotes are now regular.

All I'm doing is essentially writing out a text file, so I'm not sure what you're saying about writing text instead of XML.

Does this further explanation help with what I'm trying to achieve?

Have a look at the attached.

Archive.zip

  • Author

Thank you, but I can't go the XSL route, the XML template I'm using is pretty big, I just provided I tiny snippet in my example. Trying to transform the entire template would just be very time consuming for someone.

If it isn't possible to do it the way I have been describing I guess I go an indirect route and write out some temporary string that I can then batch replace using an AppleScript or something.

Thanks for your thoughts.

I don't see why it would be more time consuming to produce the same output in a XSLT stylesheet than in an Applescript. I prefer using XML to produce XML, because the tools are already there and one does not have reinvent the wheel.

I am not an expert on Applescript, but I believe the problem here is trying to pass the smart quotes to Applescript as text. You should construct this in the Applescript itself, rather than pass it a complete calculated string.

  • Author

Reason why the XLS thing would never happen is that I don't understand XLS, at least I understand AppleScript. :(-)

I have a workable solution now, I inserted "LEFTQUOTE" and "RIGHTQUOTE" around the "song title" and then after all of my files are written by FileMaker I run an AppleScript that replaces these temporary text items with “ and ”.

Clunky, but for my purposes it is better than where I was 12 hours ago and it works.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.