Results 1 to 4 of 4

Thread: Modifying a textfield value (easy) based on user input: charset->ansi conv.

  1. #1
    Join Date
    Aug 2006
    Posts
    239
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Modifying a textfield value (easy) based on user input: charset->ansi conv.

    I need a script that converts user input (including spaces, diacritical chars) to simple ansi string (as to be used in URLs for example). While getting the value and passing one to an input is easy- I'm stuck with the conversion problem.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,070
    Thanks
    44
    Thanked 3,216 Times in 3,178 Posts
    Blog Entries
    12

    Default

    You may want to have a look here:

    http://centricle.com/tools/ascii-hex/

    There are also the javascript methods:

    encodeURI()

    and:

    encodeURIComponent()

    and their respective decode counterparts.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Aug 2006
    Posts
    239
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Yes, but that keeps the diacritics- just encodes them. I need to replace them with their respective alphabet "root", so like: ą becomes a, ę becomes e etc.

    Something tells me that without translation "table" I won't be able to do it

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,070
    Thanks
    44
    Thanked 3,216 Times in 3,178 Posts
    Blog Entries
    12

    Default

    That wasn't clear to me before, I thought you wanted to maintain the characters. A translation table of sorts would be required, however it might be possible to employ ranges of numeric values, in that characters represented by a certain range of their ASCII or perhaps Unicode values could be acted upon with an algorithm to get their values as 'normal' characters. Or, since certain groups of 'high' characters would all translate to the same 'low' character, it could be approached that way. I'd do a search for tables and algorithms for doing just this before making my own.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •