aspose file tools*
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
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: 9502
    
    2

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: 61611
    
  67

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: 9502
    
    2

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

Joined: Oct 14, 2005
Posts: 18886
    
    8

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: 61611
    
  67

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

Joined: Sep 26, 2006
Posts: 9502
    
    2

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: 9502
    
    2

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