File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problems while parsing files in different encoding

 
Jan Kwiatkowski
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

If You want, please help me with the following:

A have a test.txt file, with single line:

Caption = Rückwärt Caption = Vorwärts Caption = Vorwärts

As you can see there are some Unicode characters like "ü"

With the following program:



I would like to display pairs (using regexp):
Caption = smth

but the output is:

Caption = &R
Caption = &Vorw
Caption = &Vorw

Those unicode characters don't won't to be printed, so as the rest of the letters after them

However this program (with no regexp, only printing this one line from the file):



prints fine:

Caption = &Rückwärt Caption = &Vorwärts Caption = &Vorwärts

It seems to be some problems with regexp's mechanism.

Could You please write what I'm doing wrong?
 
Paul Clapham
Sheriff
Pie
Posts: 20160
23
MySQL Database
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jan Kwiatkowski wrote:As you can see there are some Unicode characters like "ü"

... which are obviously not in either of the ranges "a-z" or "A-Z'. But that's what you selected. So you excluded those characters.

There's a special code in regex which means "any Unicode letter". I don't remember what it is but you could look it up in your regex reference.
 
Jan Kwiatkowski
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, thanks. I'm so dummy

the character is : \p{L}

Tanks for help
 
Paul Clapham
Sheriff
Pie
Posts: 20160
23
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right, that looks familiar.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic