Solved

ascii vs. unicode

Posted on 2002-04-26
2
1,317 Views
Last Modified: 2010-05-18
I have some functions to Encrypt and Decrypt data that is stored in a SQL Server database.  Sometimes these functions have to be javascript and sometimes they have to be vbscript...sometimes they need to be used by server code and sometimes by client code.

Here's my dilema, javascript methods(fromCharCode & charCodeAt) produce values in unicode.  I can get vbscript to operate in in unicode mode by using AscW and CharW.  As long as the data stays local, everything is fine.  I can interchange the function calls, and there is no problem.  

But, when I save the 'Encrypted' data to the database it's not equal to it's origional value back in the asp page.  Now the function that 'Encrypted' this is vbScript with the AscW & ChrW. It's like it doesn't know how to save the characters.  If I use Asc & Chr, saving the values as ascii and not unicode, things works great...until I try to 'Decrypt' with a jScript function because it's works in/with unicode and I'm supplying ascii code.  

Enough with the rambling...I guess my question is: How can I get a jScript function to work with ascii and not unicode?

Steve
0
Comment
Question by:Steve Sirica
2 Comments
 
LVL 22

Accepted Solution

by:
CJ_S earned 50 total points
ID: 6972296
You can use JScript and VBScript together, just define the languages. Then make one function in either language to save and retrieve the data.

<script language="JScript" runat="server">
function myfunc()
{

}
</script>
<script language="VBScript" runat="server">
public sub myfunction()
   myfunc()
end sub
</script>

Another way is to change the database (I think it should be sufficient, but don't pin me on it). if the database is SQL Server you can change the data type. For example nvarchar is a unicode text field. To make sure that the SQL statement is sure of it's unicode value you can use N'yourvalue' (select N'myvalue'). Oracle will have some similar manner, not access.

CJ
0
 
LVL 4

Author Comment

by:Steve Sirica
ID: 7388944
Just closing out some open questions, and you were the only one who answered, so you get the points by default.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

828 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