Solved

rhino java, javascript,   converting asc code to character value, but the compiler keeps complaining that "charCodeAt" is not found !

Posted on 2016-10-20
3
113 Views
Last Modified: 2016-10-21
Trying to read a file in JavaScript by referencing the java libraries directly, but it returns an integer for each character.

I need to convert the integer to a char value, but the compiler states that "charCodeAt(..." is not found in the String object.

Any help is appreciated.

or an easier way of just reading the text of a file ...

Thanks
0
Comment
Question by:sidwelle
[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
3 Comments
 
LVL 57

Accepted Solution

by:
Julian Hansen earned 250 total points
ID: 41853426
Can we see some source code?
0
 
LVL 16

Assisted Solution

by:krakatoa
krakatoa earned 250 total points
ID: 41853610
In mainstream Java, codePointAt(int index) in the String class returns an int, and charAt(int index) returns a char.
0
 

Author Closing Comment

by:sidwelle
ID: 41854247
Thanks for answering, Got it to work. I am working w/an undocumented version of Java inside of another product, so I don't have any documentation or any examples, but I get it to work.  Once I played around long enough with the definitions:

            var reader = new java.io.FileReader(file);      
            var sb = new java.lang.StringBuilder;
      
             while ((c = reader.read()) != -1)
             {
                   sb.append(String.fromCharCode(c));
            }
      
            if (reader != null) {
                  reader.close();
            }
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

728 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