Ticket #100 (closed defect: fixed)
Can't recognize encoding in check_encoding method
| Reported by: | denest | Owned by: | ser |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.1.7 |
| Component: | Other | Version: | 3.1.4 |
| Severity: | blocker | Keywords: | |
| Cc: | Ruby version: | 1.8.5 | |
| Operating system: | All |
Description (last modified by ser) (diff)
Hi,
in REXML::Encoding modul the check_encoding method can't give the right encoding other that utf-8 and utf-16. In the regexp match there should be \1 instead of the first \2 and the method should return $3 instead of $1. The right code is:
def check_encoding str # We have to recognize UTF-16, LSB UTF-16, and UTF-8 return UTF_16 if /\A\xfe\xff/n =~ str return UNILE if /\A\xff\xfe/n =~ str str =~ /^\s*<?xml\s*version\s*=\s*(['"]).*\1\s*encoding\s*=\s*(["'])(.*?)\2/um return $3.upcase if $3 return UTF_8 end
Change History
Note: See
TracTickets for help on using
tickets.
