Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 239475 Details for
Bug 427003
Upload of binary files with invalid UTF-8 byte sequences destroys content
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
Simple Java program demonstrating the behavior of InputStreamReader for invalid UTF-8 byte sequences
InvalidUTF8Example.java (text/x-java), 1.10 KB, created by
Michael Ochmann
on 2014-01-30 09:48:44 EST
(
hide
)
Description:
Simple Java program demonstrating the behavior of InputStreamReader for invalid UTF-8 byte sequences
Filename:
MIME Type:
Creator:
Michael Ochmann
Created:
2014-01-30 09:48:44 EST
Size:
1.10 KB
patch
obsolete
>package org.eclipse.orion; > >import java.io.File; >import java.io.FileInputStream; >import java.io.FileOutputStream; >import java.io.InputStreamReader; >import java.io.Reader; > >public class InvalidUTF8Example { > > public static void main(String[] args) throws Exception { > > // write a binary file with invalid UTF-8 sequences > File invalidUTF8 = new File("invalidUTF8"); > FileOutputStream fout = null; > try { > fout = new FileOutputStream(invalidUTF8); > fout.write(0xc0); > fout.write(0xc1); > fout.write(0xf5); > fout.write(0xf6); > fout.write(0xf7); > fout.write(0xf8); > fout.write(0xf9); > fout.write(0xfa); > fout.write(0xfb); > fout.write(0xfc); > fout.write(0xfd); > fout.write(0xff); > } finally { > fout.close(); > } > > // now read the binary file as UTF-8 > char[] buf = new char[16]; > Reader reader = null; > try { > reader = new InputStreamReader(new FileInputStream(invalidUTF8), "UTF-8"); > reader.read(buf); > } finally { > reader.close(); > } > > // InputStreamReader replaced all invalid UTF-8 sequences with \uFFFD !! > System.out.print(buf); > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 427003
: 239475