JDK-4204226 : RFE: Would like \u005C displayed as Yen Sign on Japanese systems
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: java.awt:i18n
  • Affected Version: 1.2.0,1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic,windows_98,windows_nt
  • CPU: generic,x86
  • Submitted: 1999-01-20
  • Updated: 2003-08-18
  • Resolved: 2003-08-18
Related Reports
Duplicate :  
Description

Name: gsC80088			Date: 01/19/99


Japanese Yen currency character displayed as
backslash in Appletviewer and Java plug-in.
Netscape and IE4.0 displays it correctly.
I found the difference in font.properties.ja.
Cause is 
'exclusion.sansserif.0=00b7-00b7,0100-ffff'
in font.properties.ja
It should be
'exclusion.sansserif.0=005c-005c,00b7-00b7,0100-ffff'.

[sample source]
import java.awt.Graphics;
public class PrintCurrency extends java.applet.Applet{
	String message;
        public void init() {
                message = "\\";
                resize(400,50);
        }
        public void paint(java.awt.Graphics g){
                g.drawString(message,50,20);
        }
}
(Review ID: 42665)
======================================================================

Aother customer has repored that the Yen currency is appeared as
backslash on Swing components such as JTextField.
The customer has used Java Plug-in 1.1.2_001(JRE1.1.7B, Swing1.1)
under Win32 platform.
You can easily see this behavior with the following simple Swing
applet.

import javax.swing.*;
import java.awt.*;
import java.applet.*;

public class TestField extends JApplet {

    public void init() {
      JTextField tf = new JTextField("JTextField");

      getContentPane().setLayout(new FlowLayout());
      getContentPane().add(tf);

    }
}


Name: yyT116575			Date: 07/16/2001


version "1.4.0-beta"
(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)

I am using japanese win-98 os. In this environment wherever I type backslash it gives yen symbol except in the text field. I want it to show yen symbol instead of backslash in textfield also. How shall I do that.
(Review ID: 128169)
======================================================================

Comments
PUBLIC COMMENTS Since Swing correctly represents unicode characters, the desired unicode character must be passed to Swing. On JIS systems, this means determining whether yen or backslash is intended and generating the appropriate unicode character. The Work Around contains an example JTextField that translates backslash to yen.
10-06-2004

EVALUATION [xueming.shen@Japan 1999-02-05] I don't think we are printing "Japanese Yen currency character" as backslash, actually we are printing the "\u005c" as the "backslash". In unicode the "yen sign" is "\u00a5" ("\uffe5" for fullwidth yen sign), and the "\u005c" is defined at "Reverse solidus =>blackslash", so the current behavior is correct. Yes, I am aware that in JISX0201, the code point "5c" is defined as "yen sign", and for historical reason, most of the current Japanese platforms display the "\u5c" as "yen sign", for example on Windows, if you chose the Japanese font, the "\u5c" will be displayed as "yen sign" and on Solaris, if you chose jis0201 font, you got "yen sign" too. But java is unicode based, we believe the "\u5c" should be displayed as "backslash", and if you want to display "yen sign" use "\ua5" or "\uffe5" instead. As evaluated by Sherman, \u005c in Unicode is REVERSE SOLIDUS (= BACKSLASH). The problem described in Description is not a bug. However, I'd suggest that 2D support a way of deferring this issue to user preference (i.e., the user can choose to see \u005c as either (half-width) Yen sign or Backslash). I'm changing this bug report to an RFE. masayoshi.okutsu@Eng 1999-02-08 I would consider this as an application specific preference- where there may be many such settings set up by the application for character substitution. This is similar to smart quotes or other such predefined character substitutions. parry.kejriwal@eng 1999-06-28 This issue needs to be resolved by our I18N team, not the Java 2D team. 2D will print whatever glyph our i18n code maps a Unicode character to, so it is up to the character converter code to behave correctly. thomas.ball@Eng 1999-07-09 It's a design flaw to simply use a code converter for character to glyph mappings. The current font.properties-based mapping mechanism has more issues, such as combining character rendering. masayoshi.okutsu@Eng 1999-07-11 This RFE should be kept open. Java needs to deal with the messy Japanese character set issues to be a platform for real applications. masayoshi.okutsu@Eng 1999-10-19 The Java 2D RFE 4833111 provides a new API, java.awt.GraphicsEnvironment.preferLocaleFonts, that lets applications express a preference for locale-specific fonts. Since Japanese fonts typically use the Japanese Yen as the glyph for \u005C, this gives applications a second way (besides mapping the characters as described in the Workaround section) to render \u005C as Yen. I believe this is sufficient to address the issue, and close this RFE as a duplicate of 4833111. ###@###.### 2003-08-18
18-08-2003

WORK AROUND Name: gsC80088 Date: 01/19/99 Modify font.properties.ja like below. 'exclusion.sansserif.0=005c-005c,00b7-00b7,0100-ffff'. ====================================================================== Not quite - this modification depends on the ideosyncrasies of certain converter/font combinations. A correct workaround for an application that wants to display yen instead of backslash is to replace all occurrences of \u005C in a string with \u00A5 before passing the string to the rendering routines. norbert.lindenberg@Eng 1999-07-22 Use "\uffe5" (fullwidth yen sign) for Yen Sign. masayoshi.okutsu@Eng 1999-09-02 The following java program illustrates a possible JTextField subclass that gives a workaround: import javax.swing.*; import java.awt.*; import java.awt.event.*; import javax.swing.event.*; import javax.swing.text.*; public class YenField extends JApplet { YenTextField yField; public void start() { yField = new YenTextField(" sample text \\ \u00a5 "); getContentPane().setLayout(new FlowLayout()); getContentPane().add(yField); } } class YenTextField extends JTextField implements DocumentListener { Document yDocument; public YenTextField(String s) { super(s); yDocument = getDocument(); yDocument.addDocumentListener(this); } public void insertUpdate (DocumentEvent e) { final int offset = e.getOffset(); final int length = e.getLength(); try { String insert = yDocument.getText(offset,length); if (insert.indexOf('\\') == -1) { return; } final String update = insert.replace('\\','\u00a5'); SwingUtilities.invokeLater(new Runnable() { public void run() { try { yDocument.remove(offset,length); yDocument.insertString(offset, update, null); } catch (BadLocationException ex) { } } }); } catch (BadLocationException ex) { } } public void removeUpdate (DocumentEvent e) { } public void changedUpdate (DocumentEvent e) { } } ###@###.### 1999-09-16
16-09-1999