/    Sign up×
Community /Pin to ProfileBookmark

removing latin accents

greetings!
page1.html has a form that actions Validate.php
in Validate.php I need to check for errors in the input such as if the entry is already in my database. Well one of the checks I need to make is if the input has latin accents (á,é,í,ó,ú,ü). I tried:

[code=php]$Names = $_POST[“Input”];

$Names = str_replace(“é”,”e”,$Names);
//and also
$Names = strtr($Names,”é”,”e”);[/code]

but it doesnt work.
As a bizarre tip:if I

[code=php]echo “é”;
// it outputs: A(C)[/code]

so Im not sure if it is due to a configuration thing or what….

how could I replace the accents then??

to post a comment
PHP

8 Comments(s)

Copy linkTweet thisAlerts:
@Daniel_TOct 21.2005 — There are character entities in HTML for special characters such as those. The ones you listed are like this:

á -> á

é -> é

í -> í

ó -> ó

ú -> ú

ü -> ö

Here's a [url=http://www.w3.org/MarkUp/html3/latin1.html]reference[/url].
Copy linkTweet thisAlerts:
@purefanauthorOct 21.2005 — ok.

But how does it help me?

I also have tried using Javascript:

http://www.webdeveloper.com/forum/showthread.php?t=82725

I tried applying those codes in the replacement functions and failed again ?
Copy linkTweet thisAlerts:
@purefanauthorOct 21.2005 — OH HOLY MOLLY!!!!

light has finally reached me and i havebeen enlighted with an answer to my prayers...

in validate.php

Having a list of variables getting the input by _$POST and being $Names one of them:
[code=php]
$trans = array("é" => "e", "é" => "e", "á" => "a", "á" => "a", "í" => "i","í"=>"i", "ó"=>"o", "ó" => "o", "ú" => "u", "ú"=>"u","ö" => "u", "ü"=>"u");
$Names = strtr($Names,$trans);
[/code]


it works!

I know it may sound obvious to many of you but for some reason when I first tried it simply it didnt work.

ohhh geez....I feel so relieved...??

Folks I cant be grateful enough with you, you spent so much time trying to help me...thanks!
Copy linkTweet thisAlerts:
@NogDogOct 21.2005 — [url=http://www.php.net/htmlentities]htmlentities()[/url] will allow you to output the HTML character entitiy. E.g.:
[code=php]
$test = "Here is my résumé.";
echo "<p>" . htmlentities($test) . "</p>n";
# should output 'Here is my r&eacute;sum&eacute;.'
[/code]
Copy linkTweet thisAlerts:
@bokehOct 22.2005 — What are you going with the data after it has been stored. Are you later going to display it somehow? If so stripping the accents is a bad thing as it will make the person that posted the message seem illiterate.
Copy linkTweet thisAlerts:
@ShrineDesignsOct 22.2005 — lmao, esp. if the user's language is spanish, portuguese, french, italian, and icelandic, which often use special characters like those

and not to mention japanese, korean, chinese, etc. which are almost entirely made up of special characters
Copy linkTweet thisAlerts:
@purefanauthorOct 23.2005 — I will simply output it.

I read somewhere in internet that due to the Apache configuration some servers wont handle accents properly. I ran some tests and indeed when I tried to store an accented vowel (using the specifically 'é', the ASCII code and another way which I can't remember right now) it got set in the database as a bunch of weird chars, making it imposible to read. So if I change those letters at least it will be readable.

This proyect is for keeping information related to bars and restaurants, Im using specific information about each entry such as address, province (similar to 'state') and district, so even when there could be more than one bar/restaurant with the same name it is not likely that it will be in the exact same district without being the same place.

summarizing: this whole change of accented letter is for making sure that there will be no trouble when storing the data in my database.
Copy linkTweet thisAlerts:
@bokehOct 23.2005 — That's just gargage. I store those characters straight in MySQL without any trouble whatsoever. I don't do any changes; just store them.
×

Success!

Help @purefan spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...