“Smart quotes” showing as “?” in emails

When some of my users were using my system to send emails, they’d often copy-and-paste their messages from their favourite word processor, but when my system sent the emails they’d have question marks dotted around, e.g.

“Why doesn’t this work?”

would get changed to

?Why doesn?t? this work??

Simple fix was to detect and replace those fancy-pants quote characters with the equivalent html entities, e.g.:

function enc_chars (m in varchar2) return varchar2 is
begin
  return replace(replace(replace(replace(m
    ,chr(14844060),'“')/*left double quote*/
    ,chr(14844061),'”')/*right double quote*/
    ,chr(96)      ,'‘')/*left single quote*/
    ,chr(14844057),'’')/*right single quote*/
    ;
end enc_chars;

P.S. Stupid wordpress keeps mucking around with my code, trying to replace the html entities with the unencoded versions. In case this doesn’t work, here’s an image of what the above code is supposed to look like:
enc_chars

Review all item help texts
Make Tabular Form Conditionally Read-only

Comments

  1. Gary Myers,SydOracle (@sydoracle)
    27 May 2015 - 1:35 pm

    If you want a generic solution, you can use ASCIISTR to convert the non-ASCII characters to the UTF-16 hex values, and then regexp_replace to format those as HTML entities.

    regexp_replace(asciistr(‘A“©œ®¼½¾C’),’\([0-9A-F]{4})’,’’)

  2. Hi

    I am not sure if I will get a response to this, but I wanted to give it a try….
    I am trying to run
    select regexp_replace(asciistr(‘A”©œ®¼½¾C’),’([0-9A-F]{4})’,’’)
    from dual;
    and get the below issue… and unable to resolve….
    ORA-12725: unmatched parentheses in regular expression
    12725. 00000 – “unmatched parentheses in regular expression”
    *Cause: The regular expression did not have balanced parentheses.
    *Action: Ensure the parentheses are correctly balanced.

    In my procedure, I am sending emails which has content including double quote, single quote etc and they all turn out to be ? or reversed ? and I want to rectify this….

    Please please help.

    Thanks
    Smrithi

Leave a Reply

Your email address will not be published / Required fields are marked *