Table of Contents

Article

How to replace Microsoft Word smart quotes with straight quotes in application text areas

You have a text area in your application. When you copy text that contains single or double quotation marks from Microsoft Word to the application's text area, the PRPC engine converts these characters to question mark characters (?).

This occurs when the Microsoft Word source document has smart quotes enabled. Compilers and interpreters, including the PRPC engine, cannot interpret smart (curly)quotation marks, but are able to interpret straight quotation marks.

To resolve this problem, create a new Edit-Input rule and associate it with the text area to replace Microsoft Word smart quotes with straight quotes, both for single and double quotation marks.

Example

Prerequisite condition: In Microsoft Word, the default setting for ProofingAutoCorrect is to replace straight quotes with smart quotes as you type text in Word. Check this default setting, which you should keep for formatting text when authoring content:

  1. On the File menu, click Options.
  2. In the Word Options window, click Proofing > AutoCorrect Options.
  3. Click the AutoFormat As You Type tab to see the list of elements to Replace As You Type.
  4. Verify that the check box "Straight quotes” with “smart quotes” is selected.

Next, follow these steps to see the problem:

  1. From your Microsoft Word document, copy the sentence “This is a “Susan-Test”.” into the text area of your application. This string contains smart quotes:
    Note text example with smart quotes
  2. Submit the application work form and use the Tracer to check the value of the Note text on the work page.

  3. Notice that the smart quotation marks are converted to question marks because the PRPC engine, like all compilers, cannot interpret smart quotation marks.

    TraceEvent pyNote value contains question marks

Suggested approach

Create a new EDIT INPUT rule to replace Microsoft Word smart quotes (single or double) with straight quotes, which the PRPC engine can interpret.

Continuing with the example, the following procedure shows you how to create the rule EDIT INPUT FixSmartQuotes. In this example, the rule converts the opening and closing double smart quotes from Microsoft Word to straight quotes.

You can add additional lines of Java code to fix other smart characters as needed, for example, single quotation marks.
  1. Create a new EDIT INPUT rule named FixSmartQuotes and code the Java Source as shown in the following snippet and screen.
    The first line of code replaces the opening double smart quotation mark with a straight quotation mark.
    The second line of code replaces the closing double smart quotation mark with a straight quotation mark.

    theValue = theValue.replace ("“", "\"");<br />
      theValue = theValue.replace ("”", "\"");

    EDIT-INPUT FixSmartQuotes Java Souce
  2. In the Property Work-pyNote, the Advanced tab, specify the call to the EDIT-INPUT FixSmartQuotes rule so that the automatic conversion occurs any time that smart double quotes from Microsoft Word are inserted into the pyNote property through the PRPC application user interface.
    pyNote Advanced EDIT-INPUT FixSmartQuotes
  3. Run the Tracer to see how the rule EDIT INPUT FixSmartQuotes replaces the double smart quotes copied in from Microsoft Word with double straight quotes.
    In this example, the properties for the TraceEvent for pyWorkPage show the correct text: Straight quotation marks now appear in the text as expected instead of question marks.
    TraceEvent pyNote value contains straight quotes

Reference

Smart quotes: The hidden scourge of text meant for computer consumption

Published February 6, 2015 — Updated October 2, 2015


100% found this useful

Related Content

Have a question? Get answers now.

Visit the Pega Support Community to ask questions, engage in discussions, and help others.