Reading Japanese Text

Hi,
I have a standalone program that would like to read in a text file and display in the textarea. The problem is, the text file is encoded in Japanese using JIS, EUC, and SJIS. Is there a way for me to detect, upon opening the file, which decoder to use, and how can I display the Japanese character correctly on the textarea? Please help. Thanks.
angela

Below is what I have now. It works fine. The only problem is, I'm harding it to decode using SJIS. That means I can read any files encoded using JIS or EUC. Is there a way for me to detect how the text file is encoded and use the appropriate decoder for it? Please help. Thanks.
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Japanese extends JDialog
   JScrollPane scrollPane;
   JTextArea textArea;
   JButton openButton;
   JTextField textField;
   public Japanese ()
      getContentPane().setLayout ( new BorderLayout () );
      getContentPane().setSize ( 500, 500 );
      textArea = new JTextArea ();
      scrollPane = new JScrollPane ( textArea );
      getContentPane().add ( scrollPane, BorderLayout.CENTER );
      JPanel bottomPanel = new JPanel ();
      openButton = new JButton ( "Open" );
      openButton.addActionListener ( new ActionListener ()
         public void actionPerformed ( ActionEvent e )
            textArea.setText ( "" );
            textArea.setCaretPosition ( 0 );
            openFile ( textField.getText () );
      textField = new JTextField (20);
      bottomPanel.setLayout ( new FlowLayout ( FlowLayout.LEFT ));
      bottomPanel.add ( textField );
      bottomPanel.add ( openButton );
      getContentPane().add ( bottomPanel, BorderLayout.SOUTH );                    
   private void openFile ( String filename )
      File file = new File ( filename );
      if (! file.exists () )
         System.out.println("file does not exist \n");
      else
         try
            //read file
            BufferedReader br = new BufferedReader ( new InputStreamReader ( new FileInputStream (file), "SJIS" ) );
            String nextLine = br.readLine ();
            while ( nextLine != null )
               textArea.append ( nextLine + "\n");
               nextLine = br.readLine ();
            textArea.setCaretPosition ( 0 );
         catch ( Exception exp )
            exp.printStackTrace ();
   public static void main ( String args [] )
      Japanese japanese = new Japanese ();
      japanese.show ();

Similar Messages

  • Reading Japanese Text on my C7/Astound

    Hello all. I just discovered the dictionary translator feature on my phone this morning, and downloaded the Japanese translator for it from this website. While the download was successful, none of the kana or kanji are showing up under the translations - all I'm getting is blank squares. Now I know this means that Japanese text simply isn't supported here, and that on a computer it's as simple as downloading the files and plug-ins necessary to view the text, but I haven't been able to figure out where to go or what to get for the phone to do that same thing (this is also my first smart phone too, so my tech savvy with computers only carries over so far). If anybody could tell me how to fix this I'd appreciate it. I'm in the US, if that makes a difference.

    Hello all. I just discovered the dictionary translator feature on my phone this morning, and downloaded the Japanese translator for it from this website. While the download was successful, none of the kana or kanji are showing up under the translations - all I'm getting is blank squares. Now I know this means that Japanese text simply isn't supported here, and that on a computer it's as simple as downloading the files and plug-ins necessary to view the text, but I haven't been able to figure out where to go or what to get for the phone to do that same thing (this is also my first smart phone too, so my tech savvy with computers only carries over so far). If anybody could tell me how to fix this I'd appreciate it. I'm in the US, if that makes a difference.

  • Problem reading Japanese text file

    Hi - I'm having a problem trying to read in Japanese (EUC) formatted text from a text file. When viewed as ansi, each Japanese character is displayed as two characters (e.g. ��), and there is no problem with editing them in this format in Notepad. However, BufferedReader doesn't seem to want to read some of the characters properly, for example '�'. It reads in as '?', and totally screws up what I am trying to do, which is to read in a text file regardless of its encoding, character by character. Is there any way to do this, or do I need to set up separate conditions for each possible encoding format? Is there another class I can use to read in the characters in this way? If not, how do I read in the characters properly? Thanks very much.
    -ns

    Read a text file regardless of its encoding? Nope.
    If it's encoded then you have to decode it, andit's
    up to you to specify the encoding.Pardon my ignorance, but isn't that what Unicode is
    supposed to be for? Should it be possible to write in
    a format (UTF-8?) that encompassed all the characters
    you may ever need it to?Yes, that is exactly what Unicode is supposed to be for. And yes, UTF-8 should encompass any character you ever need. But in the real world, as for example in the original poster's case, people encode their files using other standards such as EUC-JP.

  • Will not display Japanese text only boxes?

    how can I get it to display any Japanese text from websites with out it only showing boxes
    any input would be appreciated!
    The Japanese text I would love to see is
    Hiragana
    Katakana
    Kanji

    Quite honestly, I think you need to go back to Flash 10.3.183.90, a version that was kept alive specifically for WinXP users. The Flash 11 and later versions have a separate plugin container that isn't available for anything below Win Vista with feature you can't even use. I see no advantage to anything newer and on the down side the newer versions are a lot more likely to crash frequently.
    First, grab the Adobe uninstaller from here:
    http://helpx.adobe.com/flash-player/kb/uninstall-flash-player-windows.html
    Then download Flash 10.3.183.90 from here - about halfway down the page:
    http://helpx.adobe.com/flash-player/kb/archived-flash-player-versions.html
    (Released 6/11/2013) Flash Player 10.3.183.90 (61.1 MB)
    IMO, the best version of Flash for WinXP. Adobe kept up with security updates for 10.3 for WinXP users long after Flash 11.0 came out in 2011 for Vista and newer versions of Windows.
    Run the uninstaller, then reboot your operating system.
    Then you can run the Flash installer, with Firefox closed, of course.
    ''Note, if you still use IE, you'll need to reinstall the ActiveX version of Flash for IE. That uninstaller removes all versions of Flash that might be installed,''

  • Japanese text display problems in applet using plugin

    Hi,
    We've been beating our heads against the wall on this one for quite some time, so any help would be greatly appreciated.
    Our product uses a third party applet (Kavachart from Visual Engineering) to display graphical statistics from our database. We are currently localizing our product to support english and japanese. With Japanese enabled, all pages use euc-jp encoding. The problem we are running into is in the display of japanese text inside this applet in IE 5 and NS 4.7x when using the java plugin (1.3 or 1.4). If the default jre of the browsers are used, the text in the applet renders fine.
    On a suggestion from the supprot folks at Visual Engineering, I modified our code to set the defaultFont parameter on the applet to "serif, 14, 1". With this set, the text in the applet renders ok in IE, but NS on windows and unix is still broken. Given that we are doing all these tests on machines running a native japanese OS, it's not even clear to me why setting the defaultFont should even be required, but at this point, I'll take anything :-)
    Has anyone else run into this and either solved it or proven that a solution is not feasible? I'm at my wits end here....
    Thanks in advance,
    Mark Evangelisto
    Synchronicity Inc.

    If you are using different java plugin, you need to install the international version of the JRE; otherwise, some characters may not be able to display correctly since some of the properties files are missing.
    As for Visual Engineering's suggestion. I don't know why they tell you to set the default font on the applet because it may cause the browser to use the font specified. Your applet works on IE because it will try to use the best font to match the web page's content. For NS anything less then 6.0 (technology based on Mozilla), they never display web page correctly especially if you did what VE suggest.
    If you are running the applet on the native langauge OS with the international version of the JRE installed, the applet should display correctly without setting the default font. If it is not the native langauge OS, first you need to install the international version of the JRE and have the fonts that are able to display the language the applet use.

  • ITunes 8 Japanese Text Bug

    Just downloaded ITunes 8, and I discovered that when I'm modifying the name of my playlists or music the "quick" way (double clicking and then modifying the text), the text that was in Japanese characters suddenly appears as boxes (like if ITunes didn't support Japanese text). When I'm not modifying it anymore it's fine.
    ?.?

    i have this same problem. never happened until i updated to itunes 8. this does not only pertain to japanese language alone, but to all asian fonts (and i'm assuming some other foreign fonts like arabic as well).
    no problem displaying the japanese characters on the song info that's already on the songs in the first place, and no problem modifying japanese text through the "get info" palette. but like you said, when trying to modify song info through double-clicking and then edit, all the japanese characters become squares symbols.
    this also means there's no way to edit playlist titles with japanese font?

  • Report Viewer Control not displaying Japanese Text fetched from a file.

    Hi,
    I am using Crystal Report 2008.
    I want my report to display values read from text file ( this file contains key = value pairs ), for this I have created a ufl ( created as .net dll and also tested correctly).  The text file contains keys in english and theirs values in Japanese hence this text file is in UTF-8 format.
    As said above the .net dll was tested with a .net application and the japanese values were returned correctly.
    But using the same function as ufl in crystal report displays ???????? for same japanese text.
    I have already installed the Japanese language pack for crystal report.
    Please help as soon as possible.
    Thanks.

    Hi,
    I solved the above problem using setContentLocale method and passing it desired locale.
    Thanks!

  • Problem reading japanese mail subject line

    I am using
    javax.mail.Message.getSubject() method to read the Japanese subject line of the mail, but when i see the string returned by this method, it has some junk characters.
    Can anyone please tell me how to read japanese subject line?

    Hi Pothana,
    I did try to change the encoding of the Exchange server to UTF-8, but there was no difference in the result.
    Note that this problem is only in the subject line.  If I send the same text in the content it is received correctly.
    (Changing the encoding of PI is not an option... I do not have access to the Visual Administrator).
    @Ninad since I am taking the Subject from the ASMA (as suggested by SAP) I don't think that changing the content encoding of the message would make a difference.
    @Ashutosh I do have that document but I can't find anything that can help me in there.  Do you see anything that could help resolve this specific issu?
    In the mean time the problem is still there...
    Thanks for any additional help you can give me,
    Aldo

  • Offline preview differs from online display of Japanese text

    I can't figure out why my web site in English and Japanese cannot correctly display the Japanese type when uploaded. The offline preview is fine, but the online version turns the Japanese to gibberish. I have set the charset="UTF-8" in metatags and in the javascript code.
    Thinking that I may have missed a supporting file in the upload, as a test, I downloaded the entire directory and opened the file offline, but it again works fine on my desktop. The same browsers (Safari, Chrome and Firefox) used for online and offline viewing.
    Why won't my Japanese text display online when the offline preview is fine ?

    Have you set the correct charset on your webpage?  If not try to put this within the head tags on your page:
    <meta http-equiv="Content-Type" content="text/html; charset=shift_jis">
    Hope this works.

  • Copying Japanese text from Word into InDesign CS5 - possible?

    Hi,
    I created an advert in English, and now the marketer has asked me to make a Japanese version.
    They have given me a Word Document with the Japenese text in it (in more or less the same paragraph structure to the English one) with instructions of what goes where.
    When I copy the paragraps into Indesign CS5, the font is just squares and shapes, not text.
    Is it possible to get the Japanese text working in InDesign? Is there a specific font selection I have to use?
    Thanks

    The group of Japanese fonts is the one containing Kozuka Mincho.  You do not need the  World-ready composer for simple left-to-right Japanese, and non-Japanese InDesign may do what you need.  If you need Japanese-specific text processing features (e.g., vertical text, automated application of "word" breaking rules), some are available in Adobe Illustrator and explained in its help files.  Or you could try Harbs' World Tools Pro.

  • Can I use Japanese text in Dreamweaver CS4?

    Hi, I would like to make a web site with Japanese text using Dreamweaver CS4. Can someone tell me if this is easy to do, or not possible? Thank you. _Jayarny

    The head section of the page, set the characterset to UTF*, like this:
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    Then type in or paste in the Japanese text.

  • Problem using saxparser(reading japanese xml file)

    Hi everybody,
    I hav a problem while reading japanese xml file.(UTF-8 charset)
    I have to read the file and process it.
    But in the characters function of the saxparser(defaulthandler) the japanese chatracters are not read properly and the program is
    displaying some junk values(????) instead of the actual japanese characters.
    I am also usind xsd validation.
    I am not able to where the characters manipulation is being done.
    Please help me as soon as possible .
    Thanks in advance,
    Charan.

    There are a couple of things probably going on.
    1) When I've done things using Unicode unusual characters, they do not print properly if you do System.out.println( ). If you have a Gui panel and can put them into a JTextArea or JEditorPane, they may show up properly if you have set the font for that object to one that can display the characters.
    2) Many people starting with SAX write their code assuming that the characters method is only called once for each element that has text content. This is incorrect. The characters method can be called many times, and it is your responsibility to catch all of the data. In 1.4 you can use a StringBuffer, or in 1.5 there is a StringBuilder. You use these to accumulate the data from all of the calls to charactrers() between the startElement and endElement.
    Each parser can decide how often it calls characters, so you have to be able to process data from several calls.
    Dave Patterson

  • ACR 5.4 Beta shows up with Japanese Text

    hi:
    1.  i just downloaded--> installed ACR 5.4 beta and DNG.
    2.  the DNG looks normal (ie just like the prior version etc...).
    3.  however, when i open up ACR, everything is in japanese text, including the photoshop headers etc...  no big deal at this time, because i'm sure this is going to be fixed and i know what all the sliders are about etc...    but just an FYI.

    thomas:
    1.  thanks for the info.
    2.  as per what the other person noted--> what you suggested isn't that easy (basically i'm stuck).
    3.  first of all, i was able to find--> download a prior version or ACR--> manually placed it in the correct spot--> fired up a RAW file--> everything looks normal (ie english text etc...). 
    4.  i then downloaded ACR 5.4 and proceeded with the reinstall.   however at this point, the installer said that i couldn't install 5.4 because it was already installed in my cpu.    i manually looked as well as did a search for camera raw 5.4 in spotlight--> couldn't find it.    i also searched adobe photoshop help in re: unstalling things--> nothing.
    5. thus the question is:  how in the world do i uninstall camera raw 5.4 (i'm not even sure it's in my cpu but the installer thinks it is etc...).
    thanks for your help.     harry shin
    6.  by the way, while i'm at it, in adobe bridge, 5.4 doesn't recognize my Olympus E-620 raw files (ie can't see the thumbnail image), but when i actually open up the image in ACR--> the image is there etc...  thus, there's also funky going on with bridge. 

  • Javascript popup causing Japanese text transformation

    I found out that ALL the popup creating javascript
    (window.open - triggered from swf or HTML code) causes the double
    to single-byte japanese display transformation.
    This happens only on PCs, not on Macs.
    You can see the real time exemple on
    http://celine.aam-com.com/jp/
    Go to COLLECTIONS section (it shows the nav bar on the right
    with japanese letters). Then click on the HTML link in Japanese
    which opens a popup window. This slitely modify the japanese text
    (double to single-byte). On non-Japanese OS, this causes the text
    turning into little squares.

    Create the &lt;A&gt; like this
    &lt;A href="javascript:void(0)" onclick="javascript:fnPopup()">link&lt;/a&gt;
    or
    &lt;A href="javascript:fnPopup()"&gt;Link&lt;/a&gt;
    To achieve this I will type the following in URL
    javascript:void(0)" onclick="javascript:fnPopup()
    Note: there is no double quotes at the beggining and end.

  • I'm stationed and bought my iPad in Japan. How do I get my iPad to print only English (I keep getting Japanese text)?

    I'm stationed and bought my iPad in Japan. How do I get my iPad to print only English (I keep getting Japanese text)?

    Change App Store
    1. Tap "Settings"
    2. Tap "iTunes & App Stores"
    3.Tap "View Apple ID"
    4. Enter your user name and password.
    5. Tap "Country/Region."
    6. Tap "Change Country/Region"
    7. Select the region where you are located.
    8. Tap "Done".

Maybe you are looking for

  • Control through routine-sales

    Hi, Can I control field like VBAK-AUGRU through condition type reqiurement in pricing ? My scenario is if one particular condtion type (say ZCM1) is using in credit memo Sales Doc. then a particular order reason should be accepted by system & for any

  • Im trying to run a pc scan, but it keeps saying that it wont open the page, please help.

    I need to run a pc scan for something but it keeps telling me that, the page can't open.

  • CAD not saving

    Hello all, in CAD we have optoin to assign one role to multiple approver, i have added few approver for one role but when trying to save this give me error that "error saving custom approver determinator" Does anyone know why i am getting this error

  • No buffer space available

    We are executing a program that use a lot of memory, because that program read a big struct of a database in classes. It's executing properly in Win2000, but in Windows 9x ocurr this error: No buffer space available (maximum connections reached?): co

  • G700 f4 problem with Excel 2013

    I have a g700 laptop and wants to know why F4 & F2 doesn't work as usually with Excel 2013 Is there any possibility to find the same functionnality as I had with Excel 2010 before ? Thanks for your quick answer  Regards Alain Moderator Note; subject