It's not a secret anymore!
The moose likes Java in General and the fly likes Question about java.text.Normalizer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Question about java.text.Normalizer" Watch "Question about java.text.Normalizer" New topic

Question about java.text.Normalizer

Julien Martin
Ranch Hand

Joined: Apr 24, 2004
Posts: 384

I am facing an issue with my java.text.Normalizer which is working fine in one part of the application and not so well in another part of the application.

Here is how I use the Normaliser:

It works well when I use the facelets function from facelets code as shown here:

(I get this: "The+fall", notice the "+" sign.)

However, when I try to use it as follows from java code:

It does not work and I get a space as shown here:

(see: "The fall", notice the space...)

Can anyone please help?

Thanks in advance,

Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15081

Julien Martin wrote:

This is an interesting piece of code! It replaces characters with accents etc. with characters without accents. Right? So if you have something like "héllô", it will return "hello". People are sometimes asking for something like this on the forums, this looks like a good solution.

But how did you know about the regular expression "\\p{InCombiningDiacriticalMarks}+"? The character class InCombiningDiacriticalMarks is not documented in the API documentation of class java.util.regex.Pattern.

About your problem:

Sorry, I don't have a direct solution for you. But there are certain URL / HTTP parameter encodings in which spaces are replaced by + signs. Maybe your string that contains the + sign is encoded using such an encoding somewhere else in your program.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Julien Martin
Ranch Hand

Joined: Apr 24, 2004
Posts: 384
Hello Jesper,
Thanks for your reply.
Yes it looks like the spaces are replaced by "+" signs by the pretty link (see facelets/html code included in my first message).
Do you think I should replace spaces by "+" signs right from regex without waiting for my pretty link to do it?
Does anyone see a solution?
I agree. Here's the link:
subject: Question about java.text.Normalizer
It's not a secret anymore!