Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8370681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:58:17+00:00 2026-06-09T13:58:17+00:00

I tried this link already: Print in JavaCC . But for some unknown reason

  • 0

I tried this link already: Print in JavaCC. But for some unknown reason that answer didn’t work for me. I copied and pasted the text to a file and ran it, but when I inputed µ, for example, it didn’t print anything.

I want to be able to use Non-English in my string token. Just for testing purposes, right now I have:

options 
{
    UNICODE_INPUT = true;
    JAVA_UNICODE_ESCAPE = false;
}

PARSER_BEGIN(Unicode)

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;

public class Unicode
{
    public static void main(String[] args)
    {
        if(args.length == 0)
        {
            System.out.println("File name not specified!");
            return;
        }

        System.out.println("-----Start-----\n\n");
        try
        {
            FileInputStream fis = new FileInputStream(args[0]);
            InputStreamReader isr = new InputStreamReader(fis, "UTF8");

            Unicode parser = new Unicode(isr);
            parser.start();
        }
        catch(FileNotFoundException ex){
            System.out.println(ex);
        }
        catch(UnsupportedEncodingException ex){
            System.out.println(ex);
        }
        catch(ParseException ex){
            System.out.println(ex);
        }
        catch(TokenMgrError ex){
            System.out.println(ex);
        }
        System.out.println("\n\n------End-------");
    }
}

PARSER_END(Unicode)

TOKEN:{
    //         á          é          í          ó          ú
    <STR: ("\u00e1" | "\u00e9" | "\u00ed" | "\u00f3" | "\u00fa")>
}

void start():
{
    Token found;
}
{
    (
        found = <STR>
        {System.out.println("Input: " + found.image);}
    )+

    <EOF>
}

When I run the parser and feed it a file containing á, é, í, ó, ú, all I get is a bunch of question marks.

Input: ?
Input: ?
Input: ?
Input: ?
Input: ?

I’ve read something about having to modify the char stream files that are automatically generated, but I don’t really understand that.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T13:58:18+00:00Added an answer on June 9, 2026 at 1:58 pm

    This is an encoding problem between the default encoding used for a Java PrintStream, and the settings in the command shell that affect standard output.

    As the InputStream encoding is specified explicitly, and the input apparently is parsed OK, the problem is not related to JavaCC. It thus should be reproducible by this, too:

      System.out.println("\u00e1\u00e9\u00ed\u00f3\u00fa");
    

    The encoding used by the System.out PrintStream is taken from system property “file.encoding”, which on my Windows system defaults to “Cp1252” (i.e. Windows-1252). It can be forced to use something different by setting “file.encoding”, e.g.

      java -dfile.encoding=UTF-8 Unicode
    

    Also the standard PrintStream could be replaced by one that uses a different encoding:

      System.setOut(new PrintStream(System.out, true, "UTF-8"));
    

    Either of the above will force the output to be generated in a specified encoding. However when displaying the results on a console, it is important to realize what encoding is used by the shell. My Windows defaults to Cp850, and the encoding can be modified by using the chcp command. The above println will produce correct graphics by using “Windows-1252” from Java and chcp 1250.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried to do this refering to following link. http://skypher.com/index.php/2008/07/28/function-list-for-php/ But no success.
I tried this here: http://jsfiddle.net/92HXT/1/ but it does not work. It only works if
Tried this: $('.link').click(function(e) { $.getScript('http://www.google.com/uds/api?file=uds.js&amp;v=1.0', function() { $('body').append('<p>GOOGLE API (UDS) is loaded</p>'); }); return
I checked this link of S.O : Pop Images like Google Images And tried
How do I open a link in the same browser tab? I tried this
i tried to do a simple ksoap2 tutorial. This is the link My Problem
I've already tried Google searching for this and looking at the source for this
I hope I get an answer to my question this time, I already posted
I have read other questions on this topic but none that actually answers my
I already tried link from stackoverflow I have a silverlight client and wcf service.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.