Forum: Ruby-core [ruby-trunk - Bug #7593][Open] File encoding needs to be specified when using {Katakana} character p

Posted by pwim (Paul McMahon) (Guest)
on 2012-12-20 03:21
(Received via mailing list)
Issue #7593 has been reported by pwim (Paul McMahon).

----------------------------------------
Bug #7593: File encoding needs to be specified when using {Katakana} 
character property
https://bugs.ruby-lang.org/issues/7593

Author: pwim (Paul McMahon)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 1.9.3p327 (2012-11-10 revision 37606) 
[x86_64-darwin12.0.0]


Creating a file with only the following line in it:

/\p{Katakana}/

will raise the error

katakana.rb:1: invalid character property name {Katakana}: 
/\p{Katakana}/

This can be resolved by specifying

# encoding: UTF-8

However, it was not obvious to me that this was needed.
Posted by naruse (Yui NARUSE) (Guest)
on 2012-12-21 04:28
(Received via mailing list)
Issue #7593 has been updated by naruse (Yui NARUSE).

Status changed from Open to Rejected

On 1.9.3, default source encoding is US-ASCII.
Regexp escape \p{foo} in US-ASCII is interpreted as POSIX character 
class foo.
In this case, US-ASCII doesn't have POSIX character class Katakana, so 
this will raise error.

On 2.0.0, default source encoding becomes UTF-8.
So this won't happen.
----------------------------------------
Bug #7593: File encoding needs to be specified when using {Katakana} 
character property
https://bugs.ruby-lang.org/issues/7593#change-34921

Author: pwim (Paul McMahon)
Status: Rejected
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 1.9.3p327 (2012-11-10 revision 37606) 
[x86_64-darwin12.0.0]


Creating a file with only the following line in it:

/\p{Katakana}/

will raise the error

katakana.rb:1: invalid character property name {Katakana}: 
/\p{Katakana}/

This can be resolved by specifying

# encoding: UTF-8

However, it was not obvious to me that this was needed.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.