Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ascii vs. unicode

Posted on 2002-04-26
2
Medium Priority
?
1,325 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 150 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

824 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