Using Document Filters with the Japanese character sets
Not sure if this belongs here or on the Swing Topic but here goes:
I have been requested to restrict entry in a JTextField to English alphaNumeric and Full-width Katakana.
The East Asian language support also allows Hiragana and Half-width Katakana.
I have tried to attach a DocumentFilter. The filter employs a ValidateString method which strips all non (Latin) alphaNumerics as well as anything in the Hiragana, or Half-width Katakana ranges. The code is pretty simple (Most of the code below is dedicated to debugging):
public class KatakanaInputFilter extends DocumentFilter
private static int LOW_KATAKANA_RANGE = 0x30A0;
private static int LOW_HALF_KATAKANA_RANGE = 0xFF66;
private static int HIGH_HALF_KATAKANA_RANGE = 0xFFEE;
private static int LOW_HIRAGANA_RANGE = 0x3041;
public KatakanaInputFilter()
super();
@Override
public void replace(FilterBypass fb, int offset, int length, String text,
AttributeSet attrs) throws BadLocationException
super.replace(fb, offset, length, validateString(text, offset), null);
@Override
public void remove(FilterBypass fb, int offset, int length)
throws BadLocationException
super.remove(fb, offset, length);
// @Override
public void insertString(FilterBypass fb, int offset, String string,
AttributeSet attr) throws BadLocationException
String newString = new String();
for (int i = 0; i < string.length(); i++)
int unicodePoint = string.codePointAt(i);
newString += String.format("[%x] ", unicodePoint);
String oldString = new String();
int len = fb.getDocument().getLength();
if (len > 0)
String fbText = fb.getDocument().getText(0, len);
for (int i = 0; i < len; i++)
int unicodePoint = fbText.codePointAt(i);
oldString += String.format("[%x] ", unicodePoint);
System.out.format("insertString %s into %s at location %d\n",
newString, oldString, offset);
super.insertString(fb, offset, validateString(string, offset), attr);
len = fb.getDocument().getLength();
if (len > 0)
String fbText = fb.getDocument().getText(0, len);
for (int i = 0; i < len; i++)
int unicodePoint = fbText.codePointAt(i);
oldString += String.format("[%x] ", unicodePoint);
System.out.format("document changed to %s\n\n", oldString);
public String validateString(String text, int offset)
if (text == null)
return new String();
String validText = new String();
for (int i = 0; i < text.length(); i++)
int unicodePoint = text.codePointAt(i);
boolean acceptChar = false;
if (unicodePoint < LOW_KATAKANA_RANGE)
if ((unicodePoint < 0x30 || unicodePoint > 0x7a)
|| (unicodePoint > 0x3a && unicodePoint < 0x41)
|| (unicodePoint > 0x59 && unicodePoint < 0x61))
acceptChar = false;
else
acceptChar = true;
else
if ((unicodePoint >= LOW_HALF_KATAKANA_RANGE && unicodePoint <= HIGH_HALF_KATAKANA_RANGE)
|| (unicodePoint >= LOW_HIRAGANA_RANGE && unicodePoint <= LOW_HIRAGANA_RANGE))
acceptChar = false;
else
acceptChar = true;
if (acceptChar == true)
System.out.format(" Accepted code point = %x\n",
unicodePoint);
validText += text.charAt(i);
else
System.out.format(" Rejected code point = %x\n",
unicodePoint);
String newString = "";
for (int i = 0; i < validText.length(); i++)
int unicodePoint = validText.codePointAt(i);
newString += String.format("[%x] ", unicodePoint);
System.out.format("ValidatedString = %s\n", newString);
return validText;
* @param args
public static void main(String[] args)
Runnable runner = new Runnable()
public void run()
JFrame frame = new JFrame("Katakana Input Filter");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new GridLayout(2, 2));
frame.add(new JLabel("Text"));
JTextField textFieldOne = new JTextField();
Document textDocOne = textFieldOne.getDocument();
DocumentFilter filterOne = new KatakanaInputFilter();
((AbstractDocument) textDocOne).setDocumentFilter(filterOne);
textFieldOne.setDocument(textDocOne);
frame.add(textFieldOne);
frame.setSize(250, 90);
frame.setVisible(true);
EventQueue.invokeLater(runner);
}I run this code, use the language bar to switch to Full-width Katakana and type "y" followed by "u" which forms a valid Katakana character. I then used the language bar to switch to Hiragana and retyped the "Y" followed by "u". When the code sees the Hiragana codepoint generated by this key combination it rejects it. My debugging statements show that the document is properly updated. However, when I type the next character, I find that the previously rejected codePoint is being sent back to my insert method. It appears that the text somehow got cached in the composedTextContent of the JTextField.
Here is the output of the program when I follow the steps I just outlined:
insertString [ff59] into at location 0 <== typed y (Katakana)
Accepted code point = ff59
ValidatedString = [ff59]
document changed to [ff59]
insertString [30e6] into at location 0 <== typed u (Katakana)
Accepted code point = 30e6
ValidatedString = [30e6]
document changed to [30e6]
insertString [30e6] [ff59] into at location 0 <== typed y (Hiragna)
Accepted code point = 30e6
Accepted code point = ff59
ValidatedString = [30e6] [ff59]
document changed to [30e6] [ff59]
insertString [30e6] [3086] into at location 0 <== typed u (Hiragana)
Accepted code point = 30e6
Rejected code point = 3086
ValidatedString = [30e6]
document changed to [30e6]
insertString [30e6] [3086] [ff59] into at location 0 <== typed u (Hiragana)
Accepted code point = 30e6
Rejected code point = 3086
Accepted code point = ff59
ValidatedString = [30e6] [ff59]
document changed to [30e6] [ff59]
As far as I can tell, the data in the document looks fine. But the JTextField does not have the same data as the document. At this point it is not displaying the ff59 codePoint as a "y" (as it does when first entering the Hiragana character). but it has somehow combined it with another codePoint to form a complete Hiragana character.
Can anyone see what it is that I am doing wrong? Any help would be appreciated as I am baffled at this point.
You have a procedure called "remove" but I don't see you calling it from anywhere in your program. When the validation failed, call remove to remove the bad character.
V.V.
Similar Messages
-
ORACLE invoices with a Japanese character set
We are having trouble printing ORACLE invoices with a Japanese character set.
the printer we are using is a Dell W5300,do I need to configure the printer or is it something that needs to be configure in the software?????please help......We are having trouble printing ORACLE invoices with a
Japanese character set.
the printer we are using is a Dell W5300,do I need to
configure the printer or is it something that needs
to be configure in the software?????please help......What is the "trouble"? Are you seeing the wrong output? It may not be the printer, but the software that is sending the output to the printer.
If you are using an Oracle Client (SQL*Plus, FOrms, Reports etc), ensure you set the NLS_LANG to JAPANESE_JAPAN.WE8MSWIN1252 or JAPANESE_JAPAN.JA16SJIS -
Multiple phones share one Icloud account. We use it to schedule jobs and crew leaders read the cloud to get the information of the job that needs to be done. However, we recently had a change of leadership and we think this person might have logged into or put our cloud on his phone to sabotage our business. I changed the password but that didn't fix the situation. I could put a job on the cloud with an old phone that was logged in with the old password and everyone with the new password would still see the job. I have since created a whole new cloud account which seems to have eliminated the "future" issue of sabotage however I would like to completely eliminate that old account...any advise?
Everyone needs to go to Settings (or System Preferences)>iCloud and click 'Delete account' or 'Sign out' as applicable (it's the same thing). Then they can sign into the new account you have created and proceed from there. You can't actually delete the old account from the server but you can just ignore it.
-
iam using a macbook with a japanese keyboard, what should i press to change a character from romanji to kanji, the prompt ask me to type my name in kanji?
Do you have a Japanese name? If not, you would have to make one up to type it in Kanji. What exactly are you trying to do?
-
Displaying Document Name With The Summary in a Single Column Using Document Library View.
Hi All,
I have a question that relates to SharePoint Document Library Views. I want to view the Documents name with the summary in a single column. Below image shows an example of it. I need this within a SharePoint Document Library. Also I want the height of the
row to be increased more than the default height. I cannot figure it out how to do that? Could you someone help me to do this. I have inserted the Document Library as an App Part to the page.
So could you someone help me to solve this matter?
Thanks and regards,
ChiranthakaHI Chiranthaka,
You can create DataView webpart using SPD and then modify the display template according to your need.
http://deannaschneider.wordpress.com/2012/07/10/item-counts-dvwp-sp2010/
Hope this will help to solve your problem.
Best Regards,
Brij K -
Since I installed my new d6300 netgear my downloads on Apple TV have taken a lot longer than previously using a billion router. Do I need to do something with the net gear set up?
Just connect the new iPod to your computer and setup the iPod via iTunes (instead of via wifi).
If you want to copy all the infor from an old iPod touch to the inew iPod see:
iOS: Transferring information from your current iPhone, iPad, or iPod touch to a new device -
UTF/Japanese character set and my application
Blankfellaws...
a simple query about the internationalization of an enterprise application..
I have a considerably large application running as 4 layers.. namely..
1) presentation layer - I have a servlet here
2) business layer - I have an EJB container here with EJBs
3) messaging layer - I have either Weblogic JMS here in which case it is an
application server or I will have MQSeries in which case it will be a
different machine all together
4) adapter layer - something like a connector layer with some specific or
rather customized modules which can talk to enterprise repositories
The Database has few messages in UTF format.. and they are Japanese
characters
My requirement : I need thos messages to be picked up from the database by
the business layer and passed on to the client screen which is a web browser
through the presentation layer.
What are the various points to be noted to get this done?
Where and all I need to set the character set and what should be the ideal
character set to be used to support maximum characters?
Are there anything specifically to be done in my application code regarding
this?
Are these just the matter of setting the character sets in the application
servers / web servers / web browsers?
Please enlighten me on these areas as am into something similar to this and
trying to figure out what's wrong in my current application. When the data
comes to the screen through my application, it looks corrupted. But the asme
message when read through a simple servlet, displays them without a problem.
Am confused!!
Thanks in advance
ManeshHello Manesh,
For the database I would recommend using UTF-8.
As for the character problems, could you elaborate which version of WebLogic
are you using and what is the nature of the problem.
If your problem is that of displaying the characters from the db and are
using JSP, you could try putting
<%@ page language="java" contentType="text/html; charset=UTF-8"%> on the
first line,
or if a servlet .... response.setContentType("text/html; charset=UTF-8");
Also to automatically select the correct charset by the browser, you will
have to include
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> in the
jsp.
You could replace the "UTF-8" with other charsets you are using.
I hope this helps...
David.
"m a n E s h" <[email protected]> wrote in message
news:[email protected]...
Blankfellaws...
a simple query about the internationalization of an enterpriseapplication..
>
I have a considerably large application running as 4 layers.. namely..
1) presentation layer - I have a servlet here
2) business layer - I have an EJB container here with EJBs
3) messaging layer - I have either Weblogic JMS here in which case it isan
application server or I will have MQSeries in which case it will be a
different machine all together
4) adapter layer - something like a connector layer with some specific or
rather customized modules which can talk to enterprise repositories
The Database has few messages in UTF format.. and they are Japanese
characters
My requirement : I need thos messages to be picked up from the database by
the business layer and passed on to the client screen which is a webbrowser
through the presentation layer.
What are the various points to be noted to get this done?
Where and all I need to set the character set and what should be the ideal
character set to be used to support maximum characters?
Are there anything specifically to be done in my application coderegarding
this?
Are these just the matter of setting the character sets in the application
servers / web servers / web browsers?
Please enlighten me on these areas as am into something similar to thisand
trying to figure out what's wrong in my current application. When the data
comes to the screen through my application, it looks corrupted. But theasme
message when read through a simple servlet, displays them without aproblem.
Am confused!!
Thanks in advance
Manesh -
Problem displaying japanese character set in shopping cart smartform
Hi All,
whenever users are entering some text in Japanese character set while creating a shopping cart in SRM, the smartform print output is displaying some junk characters!! even though the system is unicode compatable, did any one have problem ??
Thanks.Hi,
May be there is some problem with UNICODE conversion.
See the foll links;
Note 548016 - Conversion to Unicode
http://help.sap.com/saphelp_srm50/helpdata/en/9f/fdd13fa69a4921e10000000a1550b0/frameset.htm
Europe Languages work in Non- Unicode System
Re: Multiple Backends
Re: Language issue
Standard Code Pages in Non-Unicode System
Re: Upgrade from EBP 4.0 to SRM 5.0
http://help.sap.com/saphelp_srm50/helpdata/en/e9/c4cc9b03a422428603643ad3e8a5aa/content.htm
http://help.sap.com/saphelp_srm50/helpdata/en/11/395542785de64885c4e84023d93d93/content.htm
BR,
Disha.
Do reward points for useful answers. -
My ipod is disabled and the message requests to try again in 223004 minutes. I think it might have something to do with the date being set wrong before it went into disabled mode. Can you assist in enabling.
You'll need to connect it to the iTunes library you normally sync it with and restore it. If iTunes asks you for this passcode before it will let you proceed, connect the iPod to iTunes in recovery mode instead using the instructions in this Apple support document.
iOS: Unable to update or restore
B-rock -
B2B Validation contains characters not listed in the allowed character set
Hi,
Working on EDIFACT AS2 INVOIC D05A. B2B 10g with Document Editor Version: 6.6.0.2801
payload:
UNA:+.?*'
UNB+UNOB:4::1+A1103206+XXTPHOME+20110413:0456+30000000000545'
UNH+30000000000545+INVOIC:D:05A:UN'
BGM+389+5100256812'
DTM+137:20110413:102'
DTM+143:201104:610'
FTX+CUR+++Consignment stock accounting'
RFF+AOG:0'
NAD+BY+A1103206::234++XXXXXXXXX++81379+DE'
RFF+VA:DE260978148'
CTA+PD+GC SSC ARP:Yyyy Xxxx'
COM+49(2871) 91 3481:TE'
[email protected]:EM'
NAD+SU+A1082156::234++XXXXX:::[email protected]+Nnnnn 7+Llll+DE-BY+90443+DE'
RFF+VA:DE256058056'
NAD+UC+0000000100::92++Gggg Gggg:Hhhh+Kkkkk 2+Bocholt++46395+DE'
TAX+7+VAT:::19% VAT+DE:133:86++:::19.00'
CUX+2:EUR:4'
LIN+000001++UAA3595HN/C3:VP'
PIA+1+A5B00075796235:BP'
IMD+B++:::IC DECTUAA3595HN/C3 PA V20810C6323D:670'
QTY+47:6000.000:PCE'
MOA+203:660.00'
CUX'
I try to validate payload and get 2 errors:
1. Segment COM type an min length 1 max length 512 payload value: [email protected]
Error: ub-Element COM010-010 (Communication address identifier) contains characters not listed in the allowed character set. Segment COM is defined in the guideline at position 0350.
2. Segment group 27 Sub Element CUX payload value is null, value is exists at header level (Group 7 ub-Element CUX)
Error: Unrecognized data was found in the data file as part of Loop Group 27. The last known Segment was MOA at guideline position 1260 - Validator error - Extra data was encountered.
Thanks for any help
AdiWe fix it by change Character set to UNOC
-
How to change Japanese character set
The below are my character set in my DB
NLS_CHARACTERSET=WE8ISO8859P1
NLS_NCHAR_CHARACTERSET=UTF8
Correct Answer (If I use english language the result is correct)
==========
select product(',','AB_BC ,DE') from dual;
(AB_BC, DE,,,)
After altering the parameter at session level to get Japanese character set I am getting wrong result
it is giving wrong result
==============
select product(',','A_BC ,DE') from dual;
(AB, BC , DE,,,,)
How to change at session leavel to get Japanese character setuser446367 wrote:
Correct Answer (If I use english language the result is correct)What does "use english language" mean in this context?
After altering the parameter at session level to get Japanese character set I am getting wrong resultThere is no such thing. Show us (copy paste) the commands and the resulting output, please.
select product(',','A_BC ,DE') from dual;As requested several times already in your other thread on the same subject, it would greatly help forum members to help you if you would post the pl/sql of this function.
AFAIK, product() is not a built-in standard Oracle function.
How to change at session leavel to get Japanese character setThat is probably not what's needed, but anyway, here's one simple example:
export NLS_LANG=.JA16SJIS
sqlplus u/p@svc
sql> ... -
Using Document Library with Baseline
Hi there,
I have a specific need with Sharepoint. I have a document library and I want to be able to mark with a tag or generate a baseline for my folders.
I've already searched on the web, and there is someone doing it just coping and pasting every single file. Is that the better way to get this?
Thanks,
TiagoHi Tiago,
What did you mean "Using Document Library with Baseline" and "generate a baseline for my folders"?
Did you mean that navigate the document library folders in treeview?
Did you mean that search or filter multiple folders documents with the same tag (managed metadata column)?
You may be able to use the "Navigation Hierarchies and Key Filters" for that specified SharePoint 2010 library, here is an article about metadata navigation settings you can check below,
http://www.sharepointboost.com/blog/understand-and-configure-metadata-avigation-and-filtering/
Thanks
Daniel Yang
TechNet Community Support -
What Determines the "File Character Set" on Export?
When we Export a Page, for example, from APEX, the File Character Set is defaulted to some value (and not editable). On some of our instances, this defaults to "Western European Windows 1252" while on others it is "Unicode UTF-8." Specifically, what setting is being used to make this determination? This is kind of a pain because we have some environments wherein we are promoting changes from environment to environment and these settings differ. If, during import, the user neglects to set this to the same File Character Set in which the file was originally exported, we get issues (non-printable control characters and the like). Therefore, we'd love to make all of the environments match but, aren't sure how to do this.
Thanks,
-Joe
Edited by: Joe Upshaw on Apr 10, 2013 3:25 PMHello Joe,
In your environment, the character set of the APEX exported files is set according to the DAD character set, and with your APEX version, it must be set to AL32UTF8 (regardless of the database character set).
Re: Export - File Character Set list is read only (fixe UTF-8 value)
You should check the DAD character set setting in the environments in which APEX is not exporting the files using UTF8.
Regards,
Arie.
♦ Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.
♦ Author of Oracle Application Express 3.2 – The Essentials and More -
Create a Navigational Hierarchy for filtering with the Table API
Hello,
I've built a WAD report acourding to the how to document: "Create a Navigational Hierarchy for filtering with the Table API".
It works great but i dont know How to make the hirarchey to show the key and the text.
Please Advice.
DavidHi Kenneth,
please have a look in the source of the executed Web Application. What is inside of the <div> with the id filter?
You should also find a td tag with id hier_xyz with xyz the filter inside of the <div>-Tag with id filter.
Also check whether you have a javascript error.
Have a look on the Javascript function set_style. Perhaps you can paste it here, than I can have a look.
Heike -
Can't I use my Scanner with the Elements 10 editor without the organizer??
I have been using Photoshop Elements for a looong time to help me create the product images I need for my online business. It's been a love-love relationship... until I took advantage of a special offer and bought Elements 10. Now it seems the only way I can scan images is thru the Organizer.... and the organizer is something I don't need.
Is there a way to scan my images thru the Editor only... and completely bypass the organizer (as I'm able to do with my older version of Elements)? Like a twain plugin I can install or something?
I may scan 10 images and decide to use only 3 of them... and those are the only ones I save.
With the way PSE10 is set up using the Organizer to scan, it's saving all 10 of them. Not to mention the extra steps of scanning thru the Organizer... (which means that pop-up window for my scanner every time), back over to the editor to pull the images in for editing, back to my files to delete the ones the organizer saved that I don't want... etc etc etc.
It's like 5-6 extra steps altogether and a huge time-sink for me (you know the old saying... time is money).
If there's no way to bypass the Organizer for scanning.... can I get a refund on my purchase? My older version of Elements works beautifully for me... I was just hoping for more sophisticated image editing capabilities.
VERY frustrated right now.Thank you very much for your explanation which I fully understand. Since a "fix", as you say, is not a solution might it not be a good idea to alert purchasers of the latest editions of Elements that they have an option to try this alteration to the installation in order to be able to import images from a scanner? (My own experience with versions prior to 9 always worked perfectly!) I do not know but does Photoshop CS5 allow the user to import images from a scanner or does the user have to use a similar solution to what applies to Photoshop Elements? I find Elements to be a very good app and am sure it is a good selling product for Adobe for amateur/semi-pro users that the alternative that I suggest may be a useful tool for existing or new users who want or need the capability to import from a scanner rather than having to go through other more difficulty and time consuming ways of doing the same task. Kindest regards and with my best intentions.
Fergus Cooper
Date: Tue, 20 Dec 2011 12:50:51 -0700
From: [email protected]
To: [email protected]
Subject: Can't I use my Scanner with the Elements 10 editor without the organizer??
Re: Can't I use my Scanner with the Elements 10 editor without the organizer??
created by Barbara B. in Photoshop Elements - View the full discussion
It's not a "fix", exactly. The TWAIN plug-in causes a lot of crashing in PSE so in the past couple of versions adobe makes you install it if you want it.
Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/4096095#4096095
To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/4096095#4096095. In the Actions box on the right, click the Stop Email Notifications link.
Start a new discussion in Photoshop Elements by email or at Adobe Forums
For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.
Maybe you are looking for
-
PO Conditions from SO conditions in Third party
In third party, I want to take PO Price as SO price - some value which i give in PO conditions. How can i do this by using any user-exit. Can u plz explain, how can we catch a suitable user-exit and use (in general)? Nagesh
-
Hi, I my solman system, server0 is not starting. could anyone please help me. I am attaching the trace file of server0. trc file: "D:\usr\sap\ISM\DVEBMGS00\work\dev_server0", trc level: 1, release: "700" node name : ID4047650 pid : 3496 sys
-
I have a removable usb flash drive that I've been using for a while. Occasionally I need to erase it with disk utility to remove all of the past information it has held. This time around though the drive doesn't seem to be created (I'm not sure if I'
-
Dears when i make goods receipt with reference other movement type 501 and put the cost which is differ from moving average price when i go to table MBEW to check this material with its valuation type it gives me the Moving average price not the cost
-
How can I restore lost purchased itunes?
How can I restore itune I inadvertently deleted?