Solved

ascii vs. unicode

Posted on 2002-04-26
2
1,319 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article discusses how to create an extensible mechanism for linked drop downs.
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…
Suggested Courses

628 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