This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes HTML Number encoding - User Input Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "HTML Number encoding - User Input" Watch "HTML Number encoding - User Input" New topic
Author

HTML Number encoding - User Input

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9967
    
    3

Guys,

I have a password field. The user enters some characters in it (say asdfgh12). Is there a way in HTML that before I send this password to the server, I can encode it in the HTML Number format (like {) for all the characters? Is there a special HTML function or do I have to encode it explicity using a javascript function?


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63348
    
  70

There is no such thing as an "HTML function". Any scripting on a page is done in JavaScript.

What kind of encoding are you after, and for what reason?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9967
    
    3

I want to have all the characters as &#xyz; encoded when they reach my server.
Paul Clapham
Sheriff

Joined: Oct 14, 2005
Posts: 19742
    
  10

So, instead of sending "ABC" to the server you want to send "ABC"? I'm sure you could write some Javascript to do that. The key step would be finding a Javascript function to convert a character to its Unicode code point value.

But the point of doing that escapes me too. What's the reason for doing that?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63348
    
  70

I hope that you are not thinking that this affords you any level of security.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9967
    
    3

A legacy app needs support for special characters. Migrating database to UTF-8 seems expensive. I tried with some of the characters that are supported by the current charset of the legacy app and when they reach the server, I see them by default coded as ř

For example if I enter the following hjkläb, when they reach the server, I see them as hjklêb.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9967
    
    3

Paul Clapham wrote:So, instead of sending "ABC" to the server you want to send "ABC"? I'm sure you could write some Javascript to do that. The key step would be finding a Javascript function to convert a character to its Unicode code point value.

But the point of doing that escapes me too. What's the reason for doing that?


Already wrote a javascript function that would do this for me.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HTML Number encoding - User Input
 
jQuery in Action, 3rd edition