From: laredotornado on 2 Aug 2010 10:02 Hi, I'm using Java 1.6. How do I replace all instances of a character whose int code resolves to 8217 with a UTF-8 apostrophe (e.g. "'")? - Dave
From: RedGrittyBrick on 2 Aug 2010 10:19 On 02/08/2010 15:02, laredotornado wrote: > Hi, > > I'm using Java 1.6. How do I replace all instances of a character > whose int code resolves to 8217 with a UTF-8 apostrophe (e.g. "'")? > public class ReplaceQuote { public static void main(String[] args) { String s = "-->\u8217<--"; System.out.println(s); s = s.replaceAll("\u8217", "'"); System.out.println(s); } } -- RGB
From: bugbear on 2 Aug 2010 10:26 RedGrittyBrick wrote: > On 02/08/2010 15:02, laredotornado wrote: >> Hi, >> >> I'm using Java 1.6. How do I replace all instances of a character >> whose int code resolves to 8217 with a UTF-8 apostrophe (e.g. "'")? >> > > public class ReplaceQuote { > public static void main(String[] args) { > String s = "-->\u8217<--"; > System.out.println(s); > s = s.replaceAll("\u8217", "'"); > System.out.println(s); > } > } > > I suspect the OP was thinking of "RIGHT SINGLE QUOTATION MARK" which is 8217 decimal, but 2019 hex. Since the \u (in Java) is hex, we need "\u2019" in the replacement pattern. BugBear
From: laredotornado on 2 Aug 2010 11:41 On Aug 2, 9:26 am, bugbear <bugbear(a)trim_papermule.co.uk_trim> wrote: > RedGrittyBrick wrote: > > On 02/08/2010 15:02, laredotornado wrote: > >> Hi, > > >> I'm using Java 1.6. How do I replace all instances of a character > >> whose int code resolves to 8217 with a UTF-8 apostrophe (e.g. "'")? > > > public class ReplaceQuote { > > public static void main(String[] args) { > > String s = "-->\u8217<--"; > > System.out.println(s); > > s = s.replaceAll("\u8217", "'"); > > System.out.println(s); > > } > > } > > I suspect the OP was thinking of "RIGHT SINGLE QUOTATION MARK" > which is 8217 decimal, but 2019 hex. > > Since the \u (in Java) is hex, we need > "\u2019" in the replacement pattern. > > BugBear Thanks, switching to 2019 (RIGHT SINGLE QUOTATION MARK) worked great, -
|
Pages: 1 Prev: EJB, EntityManager and merging problems Next: BuildPath Issue |