ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 28049] - sql task not able to import "windows UTF-8"
Date Tue, 30 Mar 2004 19:23:49 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=28049>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=28049

sql task not able to import "windows UTF-8"

barliguy@laposte.net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|sql task not able to import |sql task not able to import
                   |"windows UTF-8"             |"windows UTF-8"



------- Additional Comments From barliguy@laposte.net  2004-03-30 19:23 -------
In fact, according to http://www.unicode.org/unicode/faq/utf_bom.html#25 it can
have this BOM in UTF-8... It seems it's java that doesn't care of it when
openning an InputStreamReader whith "utf-8" charsetName.

To solve my problem I made a litle (and not good) hack in SQLExec.java in
runTransaction method. I replaced the line :

---
Reader reader =
                    (encoding == null) ? new FileReader(tSrcFile)
                                       : new InputStreamReader(
                                             new FileInputStream(tSrcFile),
                                             encoding);
---

with this block :

---
Reader reader = new FileReader(tSrcFile);
                
                if (reader.read() == 0xEF && reader.read() == 0xBB &&
reader.read() == 0xBF)
                {
                    reader.close();
                    //Has to be UTF8
                    reader = new InputStreamReader(new
FileInputStream(tSrcFile), "utf-8");
                    //Read the BOM char;
                    reader.read();
                }
                else
                {
                    reader.close();
                    reader =
                    (encoding == null) ? new FileReader(tSrcFile)
                                       : new InputStreamReader(
                                             new FileInputStream(tSrcFile),
                                             encoding);
                }
---

What it does? it opens the file, checks if there is the utf8 BOM (EF BB BF). If
BOM exists, open an InputStreamReader with utf8 charset and read first char (the
BOM, else do like before.

if file is less than 3 bytes, it will raise an exception I guess

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message