2

I have a form that users generally copy and paste into. When there are apostrophes in the copy and past they all turn into question marks. For example, someone just copied and pasted the title of this article:

http://brooklynheightsblog.com/archives/47796

When the user copies and pastes in a regular form that does a post, this issue occurs. However, I also have ajax submits via JSON and when done this way the apostrophes are fine from the same exact copy and paste. This method uses the Jackson json message converter.

Additionally, I checked the encoded form data and it seems fine:

Atlantic+Avenue%E2%80%99s+Sahadi%E2%80%99s+Preps+For+Wall-To-Wall+%28To+Wall%29+Expansion

I tried using an online decoder and the text decoded fine.

Anyone know what's going on with the form submit that would cause this?

Thanks!

threejeez
  • 2,314
  • 6
  • 30
  • 51

3 Answers3

2

This would be because the apostrophe being copied is not the standard ascii one. It is a special symbol that programs like word use to make there apostrophes look nicer. You would need to translate these symbols to normal ones. Could do this on browser or on server.

This could be your solution: Converting MS word quotes and apostrophes

Community
  • 1
  • 1
Solubris
  • 3,603
  • 2
  • 22
  • 37
1

You need to include a filter in your web.xml

<filter>
    <filter-name>characterEncodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
        <param-name>encoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>
    <init-param>
        <param-name>forceEncoding</param-name>
        <param-value>true</param-value>
    </init-param>
</filter>
devang
  • 5,376
  • 7
  • 34
  • 49
0

Have you tried with these attributes?

<form method="post" enctype="application/x-www-form-urlencoded" accept-charset="UTF-8" ... />
sinuhepop
  • 20,010
  • 17
  • 72
  • 107
  • Thanks for your answer. Tried this and it makes it worse: `Atlantic Avenueâ??s Sahadiâ??s Preps For Wall-To-Wall (To Wall) Expansion` – threejeez Sep 24 '12 at 00:12