This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 164820
Collapse All | Expand All

(-)a/jdk/src/share/classes/sun/awt/datatransfer/DataTransferer.java (-17 / +34 lines)
Lines 29-40 Link Here
29
import java.awt.EventQueue;
29
import java.awt.EventQueue;
30
import java.awt.Image;
30
import java.awt.Image;
31
import java.awt.Graphics;
31
import java.awt.Graphics;
32
import java.awt.Toolkit;
33
32
34
import java.awt.datatransfer.DataFlavor;
33
import java.awt.datatransfer.DataFlavor;
35
import java.awt.datatransfer.FlavorMap;
34
import java.awt.datatransfer.FlavorMap;
36
import java.awt.datatransfer.FlavorTable;
35
import java.awt.datatransfer.FlavorTable;
37
import java.awt.datatransfer.StringSelection;
38
import java.awt.datatransfer.Transferable;
36
import java.awt.datatransfer.Transferable;
39
import java.awt.datatransfer.UnsupportedFlavorException;
37
import java.awt.datatransfer.UnsupportedFlavorException;
40
38
Lines 1786-1792 Link Here
1786
     */
1784
     */
1787
    public class ReencodingInputStream extends InputStream {
1785
    public class ReencodingInputStream extends InputStream {
1788
        protected BufferedReader wrapped;
1786
        protected BufferedReader wrapped;
1789
        protected final char[] in = new char[1];
1787
        protected final char[] in = new char[2]; // #6877495
1790
        protected byte[] out;
1788
        protected byte[] out;
1791
1789
1792
        protected CharsetEncoder encoder;
1790
        protected CharsetEncoder encoder;
Lines 1839-1845 Link Here
1839
1837
1840
            try {
1838
            try {
1841
                encoder = Charset.forName(targetEncoding).newEncoder();
1839
                encoder = Charset.forName(targetEncoding).newEncoder();
1842
                out = new byte[(int)(encoder.maxBytesPerChar() + 0.5)];
1840
                out = new byte[(int)(encoder.maxBytesPerChar() * 2 + 0.5)]; // #6877495
1843
                inBuf = CharBuffer.wrap(in);
1841
                inBuf = CharBuffer.wrap(in);
1844
                outBuf = ByteBuffer.wrap(out);
1842
                outBuf = ByteBuffer.wrap(out);
1845
            } catch (IllegalCharsetNameException e) {
1843
            } catch (IllegalCharsetNameException e) {
Lines 1863-1893 Link Here
1863
            }
1861
            }
1864
        }
1862
        }
1865
1863
1864
        private int readChar() throws IOException {
1865
            int c = wrapped.read();
1866
1867
            if (c == -1) { // -1 is EOS
1868
                eos = true;
1869
                return -1;
1870
            }
1871
1872
            // "c == 0" is not quite correct, but good enough on Windows.
1873
            if (numTerminators > 0 && c == 0) {
1874
                eos = true;
1875
                return -1;
1876
            } else if (eoln != null && matchCharArray(eoln, c)) {
1877
                c = '\n' & 0xFFFF;
1878
            }
1879
1880
            return c;
1881
        }
1882
1866
        public int read() throws IOException {
1883
        public int read() throws IOException {
1867
            if (eos) {
1884
            if (eos) {
1868
                return -1;
1885
                return -1;
1869
            }
1886
            }
1870
1887
1871
            if (index >= limit) {
1888
            if (index >= limit) {
1872
                int c = wrapped.read();
1889
                // #6877495 - deal with supplementary characters
1873
1890
                int c = readChar();
1874
                if (c == -1) { // -1 is EOS
1891
                if (c == -1) {
1875
                    eos = true;
1876
                    return -1;
1892
                    return -1;
1877
                }
1893
                }
1878
1894
1879
                // "c == 0" is not quite correct, but good enough on Windows.
1895
                in[0] = (char) c;
1880
                if (numTerminators > 0 && c == 0) {
1896
                in[1] = 0;
1881
                    eos = true;
1897
                inBuf.limit(1);
1882
                    return -1;
1898
                if (Character.isHighSurrogate((char) c)) {
1883
                } else if (eoln != null && matchCharArray(eoln, c)) {
1899
                    c = readChar();
1884
                    c = '\n' & 0xFFFF;
1900
                    if (c != -1) {
1901
                        in[1] = (char) c;
1902
                        inBuf.limit(2);
1903
                    }
1885
                }
1904
                }
1886
1905
1887
                in[0] = (char)c;
1888
1889
                inBuf.rewind();
1906
                inBuf.rewind();
1890
                outBuf.rewind();
1907
                outBuf.limit(out.length).rewind();
1891
                encoder.encode(inBuf, outBuf, false);
1908
                encoder.encode(inBuf, outBuf, false);
1892
                outBuf.flip();
1909
                outBuf.flip();
1893
                limit = outBuf.limit();
1910
                limit = outBuf.limit();

Return to bug 164820