You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oro-user@jakarta.apache.org by Aarti Halleppanavar <ec...@yahoo.com> on 2002/12/27 11:54:59 UTC
Does MatchActionProcessor support Unicode?
Hi,
I am using the MatchActionProcessor. I have a file
'unicode.txt' which contains some English as well as
Japanese characters. I have another file 'regex.txt'
which contains only one line of some Japanese
characters that are present in the 'unicode.txt' file.
Both the files are saved in 'UTF-8' encoding. In my
program, I init a string by reading a line from
regex.txt and use it as a regex. The
MatchActionProcessor is unable to find matches
irrespective of whether the regex.txt contains English
or Jap content. I tried giving different encodings at
the time of creation of InputStreamReader, but to no
use. Below is the code that I am using. Is it that
MatchActionProcessor does not support Unicode
matching, or am I missing something? Can anyone please
give me an example of Unicode matching that they have
successfully tried out? I am using
jakarta-oro-2.0.7-dev-1.jar. Thanks in advance for any
help.
import java.io.*;
import org.apache.oro.text.*;
import org.apache.oro.text.regex.*;
public final class UnicodeDemo
{
public static final void main(String[] args) throws
Exception
{
//init the regex
FileInputStream fis = new
FileInputStream("regex.txt");
BufferedReader bf = new BufferedReader(new
InputStreamReader(fis/*, "UTF-8"*/));
String regex = bf.readLine();
bf.close();
System.out.println("regex used = "+regex);
MatchActionProcessor processor = new
MatchActionProcessor();
processor.addAction(regex, new MatchAction() {
//if a match is found, show it on console.
public void processMatch(MatchActionInfo info)
{
info.output.println("match found = " + ":" +
info.line);
}
});
processor.processMatches(new
FileInputStream("unicode.txt"), System.out);
}
}
Regards,
Aarti H.
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>