Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-26-2012, 07:40 PM   PM User | #1
triko
New Coder

 
Join Date: Oct 2012
Location: Italy
Posts: 72
Thanks: 3
Thanked 0 Times in 0 Posts
triko is an unknown quantity at this point
How to recognize letters accented?

Hi all guy... I have the next problem... In my code I need that program recognize the letters accented: à è ì ò ù, like a normal vowels and dont a consonant!! I have insert
Code:
<meta charset = "UTF-8" >
But nothing doesn't happen
triko is offline   Reply With Quote
Old 11-26-2012, 08:27 PM   PM User | #2
devnull69
Senior Coder

 
Join Date: Dec 2010
Posts: 2,245
Thanks: 10
Thanked 531 Times in 525 Posts
devnull69 will become famous soon enough
Sadly enough you won't even get the price for "least information possible" ... there are problem descriptions that are worse

Nevertheless: Please show us your magic code that recognizes the accented letters as consonants. How else should we know? Even my crystal ball got a headache from this ...
devnull69 is offline   Reply With Quote
Old 11-26-2012, 09:51 PM   PM User | #3
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,044
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by triko View Post
But nothing doesn't happen
The correct English is "Nothing doesn't never happen". = "Nothing happens".

I think he means that he has defined aeiou as vowels, and other letters as consonants, but now has run up against accented letters which he wants to treat as vowels.


Code:
<script type = "text/javascript">
var x=  "à á è";
if (/^[àèìòù]/.test(x)) {
alert ("String contains an accented character");
}
</script>
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.

Last edited by Philip M; 11-26-2012 at 10:09 PM..
Philip M is offline   Reply With Quote
Old 11-28-2012, 03:37 PM   PM User | #4
triko
New Coder

 
Join Date: Oct 2012
Location: Italy
Posts: 72
Thanks: 3
Thanked 0 Times in 0 Posts
triko is an unknown quantity at this point
Quote:
Originally Posted by Philip M View Post
The correct English is "Nothing doesn't never happen". = "Nothing happens".

I think he means that he has defined aeiou as vowels, and other letters as consonants, but now has run up against accented letters which he wants to treat as vowels.


Code:
<script type = "text/javascript">
var x=  "à á è";
if (/^[àèìòù]/.test(x)) {
alert ("String contains an accented character");
}
</script>
Ok, but have a problem, the program read the "à è ' ò ù" than a "?"... And then return is null because don't recognize letters accented!!!
It's for <meta> error??
triko is offline   Reply With Quote
Old 11-28-2012, 03:40 PM   PM User | #5
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,044
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by triko View Post
Ok, but have a problem, the program read the "à è ' ò ù" than a "?"... And then return is null because don't recognize letters accented!!!
It's for <meta> error??
Sorry, not a clue what you mean. You must express yourself in English more clearly.

But there was a typo in my script in Post #3 - should be

if (/[àèìòù]/.test(x)) {

^ means at the start of the string

Have a look at http://www.tuxlanding.net/how-to-dis...in-javascript/
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.

Last edited by Philip M; 11-28-2012 at 03:48 PM..
Philip M is offline   Reply With Quote
Old 11-28-2012, 04:44 PM   PM User | #6
triko
New Coder

 
Join Date: Oct 2012
Location: Italy
Posts: 72
Thanks: 3
Thanked 0 Times in 0 Posts
triko is an unknown quantity at this point
Quote:
Originally Posted by Philip M View Post
Sorry, not a clue what you mean. You must express yourself in English more clearly.

But there was a typo in my script in Post #3 - should be

if (/[àèìòù]/.test(x)) {

^ means at the start of the string

Have a look at http://www.tuxlanding.net/how-to-dis...in-javascript/
Ok, so, I found the final problem. I do convert the letters accented: "à" "è" "é" "ì" "ò" "ù", to the normal letters aeiou!! Because my program read the letters accented with consonants and I don't would this!!!
Now is it more clear?
triko is offline   Reply With Quote
Old 11-28-2012, 05:12 PM   PM User | #7
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,044
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by triko View Post
Ok, so, I found the final problem. I do convert the letters accented: "à" "è" "é" "ì" "ò" "ù", to the normal letters aeiou!! Because my program read the letters accented with consonants and I don't would this!!!
Now is it more clear?
So you are using replace() to convert accented letters into their non-accented equivalents? But why do you not simply add the accented characters to your list of vowels?
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote
Old 11-28-2012, 05:36 PM   PM User | #8
triko
New Coder

 
Join Date: Oct 2012
Location: Italy
Posts: 72
Thanks: 3
Thanked 0 Times in 0 Posts
triko is an unknown quantity at this point
Quote:
Originally Posted by Philip M View Post
So you are using replace() to convert accented letters into their non-accented equivalents? But why do you not simply add the accented characters to your list of vowels?
Because I don't say, if accented letters is vowels or consonants
triko is offline   Reply With Quote
Old 11-28-2012, 05:40 PM   PM User | #9
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,044
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by triko View Post
Because I don't say, if accented letters is vowels or consonants
Accented characters which are vowels if unaccented are still vowels if they are accented. In any European language.
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote
Old 11-28-2012, 06:59 PM   PM User | #10
triko
New Coder

 
Join Date: Oct 2012
Location: Italy
Posts: 72
Thanks: 3
Thanked 0 Times in 0 Posts
triko is an unknown quantity at this point
Quote:
Originally Posted by Philip M View Post
Accented characters which are vowels if unaccented are still vowels if they are accented. In any European language.
xD
Ok! I will remember, this! Thankssss
triko is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:06 PM.


Advertisement
Log in to turn off these ads.