Handling smart/curly quotes in Java

Hi - I want to know how to handle smart / curly quotes in Java. I need to replace them with actual quotes. I was trying somethin like below.
xmlString = xmlString .replaceAll( "‘", "'" );
but this is not working. Just tried to print indexOf( ""‘") and it only returns -1. I was trying to use the html equiv value inside i.e &#8216(folowed by semicolon. the preview replaces it with actual value)
Pls guide me on this. Its urgent!!
-Thanks,
Magesh
Edited by: magesh_rathnam on Jan 31, 2010 7:09 PM
Edited by: magesh_rathnam on Jan 31, 2010 7:10 PM

I guess not then...
Anyhow try this:
public static String replaceSmartQuotes(String smartQuotedString) {
  return smartQuotedString.replaceAll("[“”]", "\"").replaceAll("[‘’]", "'");
}{code}
Mel                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • Curly quotes

    My company is moving away from windows based servers running IIS to Linux running Apache. So now I'm running into the curly quotes issue when pasting from Word in dreamweaver CS4. I have a bunch of sites already built that will be ported over. Not to mention the fact that I get virtually all the content from Word docs. Is there any way to automatically convert  curly quotes, apostrophes, em dashes etc without having to resort to manual find and replace on every page? This has become a major issue for me and I'm wondering if there's any way to set up CS4 to automatically handle these characters when cutting and pasting from Word. DW used to do this but CS4 doesn't seem to. Any info is appreciated.
    thanks

    That is bad programming, they should not occur in these situations.
    Thank you for pointing it out I never noticed, because like 95% of the known universe I use metric measures.
    I have tried all the likely keyboard commands and searched the user manual and can not find a solution.
    I thought of replacing the auto correction with the appropriate space" and "space but this is already hard encoded in and wouldn't fix the problem. What was required in the programming was to check if there was a leading quote mark before substituting a trailing quote mark.
    Send feedback to Apple at http://www.apple.com/feedback/pages.html
    A work around is to go:
    +Menu > Edit > Special Characters… > Punctuation > and use ′ or ″ (single or double Prime)+
    These are actually the correct characters for feet and inches and will not be substituted.
    To speed it up as you type you could use auto-correction to substitute for /' and /" or whatever you think will work.

  • CS5 and DW curly quotes

    I just upgraded from CS4 to CS5. Dreamweaver used to convert curly quotes to the proper UTF encoding when you typed them in. For example, if you typed the Option-Shift-leftbracket keys you would get “ in your code. This no longer happens with CS5. It properly converts straight quotes to " but doesn't handle curly quotes or em dashes. Is there a preference or menu command that I don't know about to re-activate this feature? It would be a nightmare to have to convert all high-bit characters, especially since the app used to handle this automatically. I would consider this a major downgrade rather than an upgrade if this feature was lost.

    AdwizUSA wrote:
    I just upgraded from CS4 to CS5. Dreamweaver used to convert curly quotes to the proper UTF encoding when you typed them in. For example, if you typed the Option-Shift-leftbracket keys you would get “ in your code.
    That's not UTF-8 encoding. “ is an HTML entity that was necessary because the Western European (ISO-8859-1) encoding doesn't support curly quotes. UTF-8 does support curly quotes, so it's no longer necessary to convert them to HTML entities.
    If you switch your page encoding to Western European (ISO Latin 1), you'll get the HTML entities. If you use UTF-8, you'll get UTF-8 curly quotes.

  • Grep that finds curly quotes and changes to straight ones, but only after digits....

    Hello
    I am trying to find all the curly quotes that follow numbers and turn them into straight quotes.
    I am going to try and put this in a GREP style eventually, but in the meantime, I was testing it with find and change.
    Here is what I did......but it doesn't work.
    For the Find what- I did a positive look behind to find a digit and then pasted in the curly quote
    Fort the change to-I found the Unicode value for the straight quote.
    But it didn't work ;-(
    any thoughts out there!!
    babs

    Well, I'm no Engineer, and I suppose it would require all the font
    manufacturers to rebuild the fonts to handle it the same as small
    No...given that All Caps, is handled by InDesign without special
    font support, this feature could work the same way. A Character
    panel option (like All Caps) that Forces Straight Quotes.
    Or maybe that was your point. (?)
    It can certainly be done.
    Question is merely whether it should be done.
    But how much worse can it get than all those airplanes falling from the sky
    How could you ask such a thing? Surely having the entire universe
    sucked into a rift and enveloped in eternal blackness without sunshine,
    light, or heat is far worse than a few aluminum chassis falling into the
    ocean and there being no power grid to run InDesign unless you purchased
    the hand-crank version!

  • How to parse out curly quotes from a string

    Hi,
    I am writing a web application, where people will be copying from a Word Document into a text area. Then I get a String from the parameter passed.
    How can I parse out curly quotes and mdashes from this String? Are there specific character codes that I can parse out to replace them with regular quote characters or html quote characters?
    Thanks,
    Gabe

    Interesting problem and one that we had to deal with a couple of years ago. I think you might be talking about smart quotes and these are actually control characters used by MS products. They show up as squares in HTML unless properly dealt with. Try downloading some UNICODE charts to find out the values of these characters. I think they are something like 0044 and 0042 but I cannot remember off hand.

  • Convertin Cp1252 right curly quotes into UTF8

    I was not sure where to post this.
    I was having some problems trying to convert CP1252 right curly quote into UTF8. Other Cp1252 characters were converting correctly.
    The right curly quote was read from the database as 3 bytes. The first 2 bytes were mapping to legitimate UTF8 tokens but the third byte was not.
    According to this chart:
    http://www.io.com/~jdawson/cp1252.html
    The right curly quote is “e2809d”.
    Byte1 Byte2 Byte3
    e2 80 9d (hexadecimal)
    /342 /200 /235 (octal)
    The octals are in a big private static final Java string in sun.nio.cs.MS1252 except “/235” is missing. So the process gets the first 2 bytes right but chokes on the third.
    Hacking my own encoder class with the “/235” in the right place to made it work.
    I was wondering if this was a bug in sun.nio.cs.MS1252 ?
    Thx!
    Edited by: langal on Feb 2, 2010 10:37 PM

    Ah, the old double-encoding ploy! It looks like the text was encoded as UTF-8, then the resulting byte array was decoded as windows-1252, then the result was encoded again as UTF-8. // original string:
    ”
    // encoded as UTF-8:
    E2 80 9D
    // decoded as windows-1252 (the third character
    // is undisplayable, but valid):
    ”
    // encoded as UTF-8:
    C3 A2 E2 82 AC C2 9D The conversion to windows-1252 followed Microsoft's practice instead of its specification, so the "9D" control character is stored safely in its UTF-8 encoding, "C2 9D". Unfortunately, Java follows the spec, so getting the character back out is not so easy (and that maybe-bug is relevant--my apologies). It treats '\u009D' as an invalid character and converts it to 0x3F, the encoding for the question mark.
    I did some checking, and it seems U+201D (Right Double Quotation Mark: ”) is the only one of the added characters in the "80..9F" range that causes this problem. If the data is otherwise intact, you can work around this problem by looking for the relevant byte sequence in the intermediate processing stage and replacing it: byte[] bb0 = { (byte)0xC3, (byte)0xA2, (byte)0xE2, (byte)0x82, (byte)0xAC, (byte)0xC2, (byte)0x9D };
    // This is the string 'x' from your sample code.
    String x = new String(bb0, "UTF-8");
    System.out.println(x);  // ”
    byte[] bb1 = x.getBytes("windows-1252"); // E2 80 3F
    for (int i = 0; i < bb1.length - 2; i++)
      if ((bb1[i+2] & 0xFF) == 0x3F &&
          (bb1[i+1] & 0xFF) == 0x80 &&
          (bb1[i]   & 0xFF) == 0xE2)
        bb1[i+2] = (byte)0x9D;
    String s = new String(bb1, "UTF-8");
    System.out.println(s);  // &#x201D; The byte sequence "E2 80 3F" is unlikely to occur naturally in windows-1252, and it's invalid in UTF-8. Of course, this would only be a temporary measure, while you clean up your database as @jtahlborn said.

  • How to quickly switch between straight and curly quotes?

    I've recently moved from a Windows XP machine with MS Office to a Mac Pro with Pages.
    For the kinds of documents I typically work on, sometimes I need to have straight quotes, and sometimes curly quotes. With MS Word, I was able to create a couple of macros that would switch these preferences for me. With these macros linked to an icon in the toolbar, switching between straight and curly quotes was as easy as clicking a button.
    Now I'm looking for a way to do this -- or something like it -- with Pages.
    I know how to switch back and forth using the preferences menu, of course, but I'm looking for something quicker and simpler, since I often have to make this change several times a day.
    Can Automator do something like this? Or is there another way?
    -- Eric

    Turn off the auto correction and you can type Curly quotes with:
    left single ‘ option ]
    right single ’ option shift ]
    left double “ option [
    right double ” option shift [
    If you want the French quotes « and » they are option and option shift |
    Peter

  • Pages '09 integrating straight and curly quotes within one file.

    I'm doing an edit in Pages and the document has a mix of straight and curly quotes. I can't seem to find a way to get them all the same. Find-and-replace turns some of the quotes backwards (as in 'em for them) Nothing in the archives addresses this.

    Look for patterns in search and replace.
    Search for a space + " to get the leading quote and " + space to get a trailing quote.
    Or get WordServices to fix all this.
    Peter

  • Handling exception logging in a Java task scheduler program?

    I need to design a Task Scheduler Where
    1) User should be able to schedule multiple task at the same time.
    2) There should be proper error handling on failure of any task and should not affect the other running tasks.
    I found the related programme at http://www.roseindia.net/java/example/java/util/CertainAndRepeatTime.shtml
    My concern is about handling of point 2 in program provided at above link. Say I schedule a recurring mail send process in above program which will be run first time on 12 september 2011 at 2 am, and will be repeated after every 2 hours Say a one process fais at 8 am. I want to log it in log file with task name and time details. Now if I look at above programme i.e CertainAndRepeatTime.java. This program will exit once it schedules all the tasks. Where and how should handle the logging?
    Posted at http://stackoverflow.com/questions/7377204/handling-exception-logging-in-a-java-task-scheduler-program but folks suggesting Quartz scheduler . My Limitation is that i can't for quartz because my project allows me to use only standard java library. Is there any way we can handle logging in the same programme in case of exception.

    Well, first of all I wouldn't trust any code from roseindia. So you might want to look for more reliable advice.
    As for your logging, you can add it for example to the TimerTask itself. I don't recommend adding logging to that roseindia cr*p though.

  • Error handle request; Root exception is: java.lang.NoSuchMethodError

    Hello Guys,
    I am running EBS 11i, rdbms 10g on OEL4. After applying a bunch of patches to resolve some IE issues I ran into an error:
    "FRM-41072: Cannot create group ACTION_REC_GROUP" when trying to cancel a PO.
    An SR directed me to apply patch 8286920 which indeed fixed the FRM-41072 error. After this patch "Logon to Oracle Applications Manager" is not possible as the page gives me :
    Error handle request; Root exception is: java.lang.NoSuchMethodError: oracle.apps.fnd.security.AolSecurity.userPwdHash(Ljava/lang/String;)Ljava/lang/String;
    MOS thinks that patch 8286920 didn't break OAM but I don't think so since this is only happening on my DEV and TEST systems on which I have applied the patch. PROD, wihtout the patch, is accessible through OAM just as usual?
    Any thouths?
    Thank you
    Mathias

    Did you apply all patches mentioned in the following docs?
    FRM-41072 - Unable to Cancel Purchase Order or Purchase Order Line or Release [ID 947402.1]
    Change Tax Code in the Purchase Order Gets Error - Could not reserve record (2 tries) Keep trying [ID 956047.1]
    Autocreate Process Does Not Default Purchase Order Form As The Active Window After PO Is Created - Does Not Come To The Front [ID 1055623.1]
    Did you bounce all the services and see if you ca reproduce the issue?
    What about clearing the server cache files? -- How To Clear Caches (Apache/iAS, Cabo, Modplsql, Browser, Jinitiator, Java, Portal, WebADI) for E-Business Suite? [ID 742107.1]
    Can you find any errors in the database/apache log files? Any invalid objects?
    If you have verified all the above please update the SR with the error you have after applying that patch.
    Thanks,
    Hussein

  • Curly quotes in titles in Premiere Pro CS4 - how to get them?

    How can I get the titler text tool to give me proper typographer's curly quotes instead of the inch marks? Is using Alt0147 and Alt0148 the only way?
    Thanks

    Use the character map.  You can see what you want to select.
    I use it all the time for special characters. 

  • Call handling smart extension

    Call handling smart extension Because the block Smart connect resulting in disconnection
    Can not use it Smart Watch 2
    Android 4.4.3 and 4.4.4

    I just did a test and i was able to replicate this so this needs to be escalated.
    Could you please send me your details in a PM, and I will forward this.
    Make a relevant topic and include the following.
    Name:
    Phone nr:
    E-mail:
    Country:
    Operator:
    Product(s):
    IMEI nr:
    Build number:
     - Community Manager Sony Xperia Support Forum
    If you're new to our forums make sure that you have read our Discussion guidelines.
    If you want to get in touch with the local support team for your country please visit our contact page.

  • Smart Card Winlogon using Java

    Hey,
    Is it possible to develop Smart Card Winlogon using Java.?
    Can the Java programming interact with MsGina.Dll?
    Is there any alternative method to perform such task apart from the above?
    Thanks in Advance
    LOOI

    To interact with a Windows DLL you need to use JNI.

  • Endash and curly quote HTML errors

    I inherited a large knowledge base at my job that was using
    RoboHelp x5. It hadn't been worked on for more than a year when I
    started, so the first thing I did was upgrade to RoboHelp 7. (I am
    a total Robohelp beginner; been learning on my own since starting
    her in Jan. 08) The first time I generated an output and published
    the knowledge base in 7, we began to discover the project is
    riddled with <&endash;> and <&rdquor;> HTML
    errors. RH x5 version read the endash and curly quotes fine and
    displayed the characters.
    What can I do now? Is there a global find and replace? What's
    also weird is that the endash looks OK in the RoboHelp viewer. The
    curly quote does show up wrong in the RH viewer as
    <”r;>.
    Any help or insight would be much appreciated. Thanks!

    Thanks for your response, Peter. Don't see the patch you
    mention -- could you point me to it? I may not be able to use it
    tho, b/c have made lots of edits and updates to our knowledge base
    so I can't go back to the old R5 copy at this point.
    If not, I will try the Helpware FAR. In looking at their
    site, am not sure how it works: do I apply it to the output file or
    the RH project files.
    Thanks!

  • How we can handle the below doubt in Java Script!!

    Hi All,
    I need to handle the below scenerio in javascript, i am very poor in scripting langauage could any help me out.
    Below are the three where we have specail character
    words as
    1. transfer (…)
    2. Shell’s
    3. Vitol – as
    The above 3 are having some specail characters which we need to
    replace as mentioned below
    need to use a Function/Method in some scripting language like Java
    script to replace the special character with a predefined sequence eg:
    single quote with “a1b1” before inserting the data in to the data base
    and then while retrieving the record from the database replace “a1b1”
    with single quote.
    Note#:It is a text area where user can either enter or copy and paste
    the content.
    Thanks,
    Anoo..

    Hi Anoo,
    always remember to put your apex and database versions, it makes it easier to help.
    You mentioned stripping out special characters and then putting them back for display. Is there a particular reason why?
    If you're having difficulty querying the 'special' characters from SQL, you can create a view to handle that complexity.
    The examples you gave don't contain any characters you can't query on. Maybe I'm missing something.
    Kofi

Maybe you are looking for

  • OS X 10.8.3 breaks Displays preferences, introduces serious bug

    Looks like Apple introduced a nasty bug with all the supposed bug fixes that came with OS X 10.8.3. After installing (and also trying a clean install) OS X 10.8.3, my Display configuration changes on its own, typically when waking from sleep, but it

  • User-managed image gallery in template-based html site?

    I've created a simple, template-based html/css site for a client and they've asked for a set of sales pages for their vans and cars.  The idea is that there'll be an entry page, which has an itemised list (thumbnail pic, title and a couple of sentenc

  • Restrictive pdf control plug-in?

    Hello Is there a plug-in for acrobat that restricts the manipulation of 3D models? I want to provide a 3D model that can be viewed from all angles, but nothing else.

  • Restoring only the tablespace from the database

    How do we restore only a 'tablespace' from a Terabyte database without restoring the entire database. ie... if a particular tablespace has been dropped from the database and we have the backup available for the database. So, how do we go about it for

  • IPad mini is frozen

    I have a window saying my ipad has not been backed up on icloud in over 2 weeks and needs to be plugged in, locked, and connected to wifi to do so.  I did this and the message still remains.  I can not even power off the ipad with this window up.  Ho