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
54 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
3 Comments
 
LVL 51

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now