473,394 Members | 1,718 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

string to ascii javascript

I have the following code for converting string to ascii but I would like to add the values. The following code does not add the values;

Expand|Select|Wrap|Line Numbers
  1. var str = owner.value
  2.         var code
  3.     strLength = owner.value.length
  4.     for (i =0;i<strLength;i++){
  5.     code =  str.charCodeAt(i);
  6.  
  7.     alert(code);
  8.  
I would appreciate any help.

Kshetarpal
Feb 7 '08 #1
1 1759
gits
5,390 Expert Mod 4TB
how would you add the values? simply adding them could be done with the following example:

Expand|Select|Wrap|Line Numbers
  1. var str       = 'abcd';
  2. var code      = 0;
  3. var strLength = str.length;
  4.  
  5. for (var i = 0; i < strLength; i++) {
  6.     code += parseInt(str.charCodeAt(i), 10);
  7. }
  8.  
  9. alert(code);
  10.  
kind regards
Feb 7 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Erinys | last post by:
Hi, I need to access the individual bytes in a string in my javascript function. If the characters in the string were all ascii characters then there would not be a problem, however in my case...
5
by: ken | last post by:
hello, i'm using charCodeAt to get the ascii value at a given location in a string but now i want to set the value of a location in a string to a specific ascii value. is there a way to do this?...
32
by: Wolfgang Draxinger | last post by:
I understand that it is perfectly possible to store UTF-8 strings in a std::string, however doing so can cause some implicaions. E.g. you can't count the amount of characters by length() | size()....
11
by: Kai Bohli | last post by:
Hi all ! I need to translate a string to Ascii and return a string again. The code below dosen't work for Ascii (Superset) codes above 127. Any help are greatly appreciated. protected...
18
by: Ger | last post by:
I have not been able to find a simple, straight forward Unicode to ASCII string conversion function in VB.Net. Is that because such a function does not exists or do I overlook it? I found...
4
by: http://www.visual-basic-data-mining.net/forum | last post by:
Hi Does anyone know how to stay connected to the server and at the same time i can pass the string to and from the module to the form..... What I want: I put the connection at the...
2
by: VK | last post by:
Does anyone have a reputable reference about internal string storage in JavaScript? (for some particular implementation I mean). Say having 1,048,576 characters long string from the geometric...
1
Atli
by: Atli | last post by:
The following small HowTo is a compilation of an original problem in getting some cookie-values through different methods of string-handling. The original Problem was posted as follows: As...
19
by: est | last post by:
From python manual str( ) Return a string containing a nicely printable representation of an object. For strings, this returns the string itself. The difference with repr(object) is that...
2
by: Gabriela | last post by:
Hi, I need help with writing a regexp that identifies HTML encoded strings. The problem occurred because I have a field in the DB, that contains regular ASCII chars, as well as HTMLencoded...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.