www.webdeveloper.com
Results 1 to 4 of 4

Thread: Spanish accent problem

  1. #1
    Join Date
    Mar 2005
    Posts
    53

    Unhappy Spanish accent problem

    Hi, I have a submission form that contains field values that have letters with accents. Also a textarea field that a person can type characters with accents. The problem is when the page is submitted it goes to a page that reads the information and then generates an auto acknowledgement letter to the person and to us. The accents then are converted to ó not what they actually are supposed to be. I have tried both the html way of inserting accents (&oacute and copy and paste the () but no luck. Any solutions for this.

  2. #2
    Join Date
    Jun 2008
    Location
    Europe
    Posts
    1,086
    I have this same issue with PHP, I finally gave up and used a string replacement routine.

  3. #3
    Join Date
    Mar 2005
    Posts
    53
    What kind of string replacement routine did you use? Do you have an example? Also, I would be doing this in asp so I am sure it would be different but maybe I can get an idea if I saw it. Thanks. Oh and by the way when I test it in IE I get totally different symbols than in Mozilla. Go figure

  4. #4
    Join Date
    Jun 2008
    Location
    Europe
    Posts
    1,086
    I use PHP, and here is what I have:

    Global Foreign Character fix script:
    PHP Code:
    <?php 

    $string 
    "Cześć";

    // allhtmlentities : mainly based on "chars_encode()"  by Tim Burgan <timburgan@gmail.com> [http://www.php.net/htmlentities]
     
    function allhtmlentities($string) { 
        if ( 
    strlen($string) == 
            return 
    $string
        
    $result ''
        
    $string htmlentities($stringHTML_ENTITIES); 
        
    $string preg_split("//"$string, -1PREG_SPLIT_NO_EMPTY); 
        
    $ord 0
        for ( 
    $i 0$i count($string); $i++ ) { 
            
    $ord ord($string[$i]); 
            if ( 
    $ord 127 ) { 
                
    $string[$i] = '&#' $ord ';'
            } 
        } 
        return 
    implode('',$string); 


    echo 
    $string;
    ?>
    A simple string replacement with HTML equivalents... I use something like this in a JavaScript email encryption script I wrote.

    PHP Code:

    $ent 
    = array( 
    'a'=>'&#97;',
    'b'=>'&#98;',
    'c'=>'&#99;',
    'd'=>'&#100;',
    'e'=>'&#101;',
    'f'=>'&#102;',
    'g'=>'&#103;',
    'h'=>'&#104;',
    'i'=>'&#105;',
    'j'=>'&#106;',
    'k'=>'&#107;',
    'l'=>'&#108;',
    'm'=>'&#109;',
    'n'=>'&#110;',
    'o'=>'&#111;',
    'p'=>'&#112;',
    'q'=>'&#113;',
    'r'=>'&#114;',
    's'=>'&#115;',
    't'=>'&#116;',
    'u'=>'&#117;',
    'v'=>'&#118;',
    'w'=>'&#119;',
    'x'=>'&#120;',
    'y'=>'&#121;',
    'z'=>'&#122;',
    'A'=>'&#65;',
    'B'=>'&#66;',
    'C'=>'&#67;',
    'D'=>'&#68;',
    'E'=>'&#69;',
    'F'=>'&#70;',
    'G'=>'&#71;',
    'H'=>'&#72;',
    'I'=>'&#73;',
    'J'=>'&#74;',
    'K'=>'&#75;',
    'L'=>'&#76;',
    'M'=>'&#77;',
    'N'=>'&#78;',
    'O'=>'&#79;',
    'P'=>'&#80;',
    'Q'=>'&#81;',
    'R'=>'&#82;',
    'S'=>'&#83;',
    'T'=>'&#84;',
    'U'=>'&#85;',
    'V'=>'&#86;',
    'W'=>'&#87;',
    'X'=>'&#88;',
    'Y'=>'&#89;',
    'Z'=>'&#90;',
    '@'=>'&#64;',
    '-'=>'&#45;',
    '.'=>'&#46;',
    '_'=>'&#95;'
    ); 

    $string strtr("$string"$ent);
    $privacy strtr("$privacy"$ent);
    $string str_replace('&''&amp;'$string);
    $privacy str_replace('&''&amp;'$privacy);
    $astring "<a href=\"$string\">$privacy</a>"//test
    echo "$astring"

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles