Solved

ascii vs. unicode

Posted on 2002-04-26
2
1,314 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
Comment Utility
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
Comment Utility
Just closing out some open questions, and you were the only one who answered, so you get the points by default.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Problem to Popup 2 48
Change text when typing into field 2 20
using web browser with BING 40 84
Hidden Field Value 10 34
This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now