mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
2004-12-21 Alain Magloire
purpose: using charset from 'file' to encode in-memory String object into bytes modifer: Wu Zhi Qiang action: first get the charset from 'file', then use it to encode the 'buffer.toString()' into bytes * src/org/eclipse/cdt/internal/core/model/Util.java
This commit is contained in:
parent
2c4cc97119
commit
e789bb0fd3
2 changed files with 28 additions and 5 deletions
|
@ -1,3 +1,10 @@
|
|||
2004-12-21 Alain Magloire
|
||||
purpose: using charset from 'file' to encode in-memory String object into bytes
|
||||
modifer: Wu Zhi Qiang
|
||||
action: first get the charset from 'file', then use it
|
||||
to encode the 'buffer.toString()' into bytes
|
||||
* src/org/eclipse/cdt/internal/core/model/Util.java
|
||||
|
||||
2004-12-09 Alain Magloire
|
||||
Fix for 80724: not showing initialized global variables.
|
||||
* utils/org/eclipse/cdt/utils/coff/parser/CygwinPEBinaryObject.java
|
||||
|
|
|
@ -111,11 +111,27 @@ public class Util implements ICLogConstants {
|
|||
|
||||
public static void save(StringBuffer buffer, IFile file)
|
||||
throws CoreException {
|
||||
byte[] bytes = buffer.toString().getBytes();
|
||||
ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
|
||||
// use a platform operation to update the resource contents
|
||||
boolean force = true;
|
||||
file.setContents(stream, force, true, null); // record history
|
||||
String encoding = null;
|
||||
try {
|
||||
encoding = file.getCharset();
|
||||
} catch (CoreException ce) {
|
||||
// use no encoding
|
||||
}
|
||||
|
||||
byte[] bytes = null;
|
||||
if (encoding != null) {
|
||||
try {
|
||||
bytes = buffer.toString().getBytes(encoding);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
} else {
|
||||
bytes = buffer.toString().getBytes();
|
||||
}
|
||||
|
||||
ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
|
||||
// use a platform operation to update the resource contents
|
||||
boolean force = true;
|
||||
file.setContents(stream, force, true, null); // record history
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue