Click here to Skip to main content
15,888,733 members
Home / Discussions / C#
   

C#

 
AnswerRe: String.fromCharCode and charCodeAt Pin
tim_gunning4-Jul-08 6:42
tim_gunning4-Jul-08 6:42 
AnswerRe: String.fromCharCode and charCodeAt Pin
Guffa4-Jul-08 6:43
Guffa4-Jul-08 6:43 
GeneralRe: String.fromCharCode and charCodeAt Pin
tim_gunning4-Jul-08 9:17
tim_gunning4-Jul-08 9:17 
AnswerRe: String.fromCharCode and charCodeAt Pin
Guffa4-Jul-08 12:44
Guffa4-Jul-08 12:44 
GeneralRe: String.fromCharCode and charCodeAt [modified] Pin
tim_gunning4-Jul-08 14:27
tim_gunning4-Jul-08 14:27 
GeneralRe: String.fromCharCode and charCodeAt Pin
Guffa4-Jul-08 14:38
Guffa4-Jul-08 14:38 
GeneralRe: String.fromCharCode and charCodeAt Pin
tim_gunning4-Jul-08 14:49
tim_gunning4-Jul-08 14:49 
GeneralRe: String.fromCharCode and charCodeAt Pin
Guffa5-Jul-08 3:32
Guffa5-Jul-08 3:32 
tim_gunning wrote:
in c# i used
Convert.ToBase64String(Encoding.ASCII.GetBytes(my_str))


The ASCII encoding only handles characters with character code 0 to 127. To get the equivalent of the JScript code you would have to loop through the string and get the character codes into a byte array, so that you get the characters with character codes from 0 to 255.

The JScript code claims to encode a string to base64, but that it not really possible. It assumes that there are never any character codes above 255. If there is, the result will be incorrect.

To correctly turn a string into base64, you first have to encode it using an encoding that can handle the full unicode character set, like UTF-8:

Convert.ToBase64String(Encoding.UTF8.GetBytes(my_str))

Despite everything, the person most likely to be fooling you next is yourself.

GeneralRe: String.fromCharCode and charCodeAt Pin
tim_gunning6-Jul-08 2:08
tim_gunning6-Jul-08 2:08 
GeneralRe: String.fromCharCode and charCodeAt Pin
N a v a n e e t h4-Jul-08 16:45
N a v a n e e t h4-Jul-08 16:45 
GeneralRe: String.fromCharCode and charCodeAt Pin
Guffa5-Jul-08 3:18
Guffa5-Jul-08 3:18 
GeneralRe: String.fromCharCode and charCodeAt Pin
N a v a n e e t h5-Jul-08 16:33
N a v a n e e t h5-Jul-08 16:33 
Questionwindows service Pin
arkiboys4-Jul-08 4:55
arkiboys4-Jul-08 4:55 
AnswerRe: windows service Pin
Michael90004-Jul-08 8:17
Michael90004-Jul-08 8:17 
AnswerRe: windows service Pin
N a v a n e e t h4-Jul-08 18:43
N a v a n e e t h4-Jul-08 18:43 
QuestionAccess Denied to AllUsers Folder Pin
Richard Blythe4-Jul-08 4:43
Richard Blythe4-Jul-08 4:43 
AnswerRe: Access Denied to AllUsers Folder Pin
Daniel Grunwald5-Jul-08 7:27
Daniel Grunwald5-Jul-08 7:27 
GeneralRe: Access Denied to AllUsers Folder Pin
Richard Blythe5-Jul-08 16:24
Richard Blythe5-Jul-08 16:24 
QuestionRe:How to find out unused registry keys Pin
RameshwerE4-Jul-08 3:54
RameshwerE4-Jul-08 3:54 
AnswerRe:How to find out unused registry keys Pin
Simon P Stevens4-Jul-08 3:58
Simon P Stevens4-Jul-08 3:58 
AnswerRe:How to find out unused registry keys Pin
Christian Graus4-Jul-08 9:21
protectorChristian Graus4-Jul-08 9:21 
Questionhow to restart application after updating version Pin
asma_panjabi4-Jul-08 1:39
asma_panjabi4-Jul-08 1:39 
AnswerRe: how to restart application after updating version Pin
N a v a n e e t h4-Jul-08 2:10
N a v a n e e t h4-Jul-08 2:10 
GeneralRe: how to restart application after updating version Pin
asma_panjabi4-Jul-08 2:13
asma_panjabi4-Jul-08 2:13 
GeneralRe: how to restart application after updating version Pin
leppie4-Jul-08 4:33
leppie4-Jul-08 4:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.