Tactic
Tactic

Reputation: 103

Adapt Pascal function AnsiChar() and AnsiString() in JavaScript?

i need to adapt a pascal script into JavaScript. I was able to translate nearly all the code except this two functions.

Pascal codelines:

Result:= AnsiChar(b + ord('0'));

s:= AnsiString(copy(ReNr, 1, length(ReNr) - 1));`

The code in the AnsiChar()-function i already adapt with '0'.codePointAt(0) % 10, and the code in the AnsiString() with ReNr.substr(1, ReNr.length - 1). But i don't understand what the Pascal Ansi-functions does.

Is there a JavaScript pendant to Pascals AnsiChar() and AnsiString() functions or what i have to do, to get the same effect in JavaScript?

Upvotes: 0

Views: 114

Answers (1)

DoctorWhoWho
DoctorWhoWho

Reputation: 23

I belive it will be something like this:

Result = String.fromCharCode(b + '0'.charCodeAt(0) );

S = ReNr.substring(0, ReNr.length - 2);

Delphi's AnsiChar() creates a character from a given ASCII code.

AnsiString converts string to Ansi encoding if it was in multibyte.

Upvotes: 0

Related Questions