Solved

javascript toUpperCase() giving problem for utf-8

Posted on 2006-06-12
8
2,098 Views
Last Modified: 2009-10-12
for UTF-8 i am using encodeURIComponent method ;its working fine for all cases except  some characters like alt159 when i use javascript toUpperCase() its coming box character

encodeURIComponent(document.getElementById("XXXXX").value.toUpperCase())
0
Comment
Question by:chaitu chaitu
  • 4
  • 2
  • 2
8 Comments
 
LVL 20

Expert Comment

by:REA_ANDREW
ID: 16885333
Have you confirmed that these characters do have UPPER CASE variations, as doing this would result in the systems returning a Square Character as your request is invalid. i.e. what is the UPPER CASE alt code for alt159

Andrew
0
 
LVL 20

Expert Comment

by:REA_ANDREW
ID: 16885357
FOr validation purposes, you could apply an onblur event or onkeyup, which would perform a Replace on a range on Alt Codes in the Target Value. Meaning that when you come to perform the toUpperCase method, no character is there that you are unprepared for. A lit of these ranges can be found here

http://www.tomwilson.com/david/accents/Alt_key_chars.doc
0
 
LVL 20

Author Comment

by:chaitu chaitu
ID: 16885384
when i enter alt159 it will come as ƒ;
when user enter any characters i am converted into upperCase.when user entered above special character also i am doing same thing;then its giving problem.that special character turns into square bracket.at that time what is the remedy
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 20

Author Comment

by:chaitu chaitu
ID: 16885422
i am not doing validation;i am preparing url here in javascript and send it to another page;
0
 
LVL 20

Author Comment

by:chaitu chaitu
ID: 16885549
"hich would perform a Replace on a range on Alt Codes in the Target Value"

how can i perform a  a Replace on a range on Alt Codes ??
0
 
LVL 20

Author Comment

by:chaitu chaitu
ID: 16891873
first tell me Is alt159 is special character or UTF character
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 500 total points
ID: 16892938
And also here you can adapt the return values in the toUpper() function to what you need:

<script>


function toUpper(theStr){
  return theStr.replace(/[a-z]/g,function(p){return p.toUpperCase()});
}


alert(toUpper("Zvonko"));
</script>

0
 
LVL 63

Expert Comment

by:Zvonko
ID: 16893515
Is this now answered too?
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question