Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about java.text.Normalizer

 
Julien Martin
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

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,

Julien.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15203
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Julien Martin
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
Julien.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic