diff options
author | PJ Fanning <fanningpj@apache.org> | 2022-07-15 21:52:32 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2022-07-15 21:52:32 +0000 |
commit | 87ee700d04af1fea764c0762f0fb5dada4411295 (patch) | |
tree | fadbb626410244764c087b4ed23cc467eed76764 /poi-scratchpad | |
parent | 70bd85fda41f885427e3db8d5b32eb71656f8eb0 (diff) | |
download | poi-87ee700d04af1fea764c0762f0fb5dada4411295.tar.gz poi-87ee700d04af1fea764c0762f0fb5dada4411295.zip |
[github-340] make more use of StandardCharsets. Thanks to XenoAmess. This closes #340
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1902755 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-scratchpad')
4 files changed, 8 insertions, 5 deletions
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hdgf/chunks/Chunk.java b/poi-scratchpad/src/main/java/org/apache/poi/hdgf/chunks/Chunk.java index 19eda1e7f7..b85592f112 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hdgf/chunks/Chunk.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hdgf/chunks/Chunk.java @@ -222,7 +222,7 @@ public final class Chunk { } int strLen = endsAt - startsAt; - command.value = new String(contents, startsAt, strLen, header.getChunkCharset().name()); + command.value = new String(contents, startsAt, strLen, header.getChunkCharset()); break; case 25: command.value = LittleEndian.getShort(contents, offset); diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hdgf/chunks/ChunkHeaderV4V5.java b/poi-scratchpad/src/main/java/org/apache/poi/hdgf/chunks/ChunkHeaderV4V5.java index 97be9616e8..cd61da75fe 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hdgf/chunks/ChunkHeaderV4V5.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hdgf/chunks/ChunkHeaderV4V5.java @@ -18,6 +18,7 @@ package org.apache.poi.hdgf.chunks; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; /** * A chunk header from v4 or v5 @@ -59,7 +60,7 @@ public final class ChunkHeaderV4V5 extends ChunkHeader { @Override public Charset getChunkCharset() { - return Charset.forName("ASCII"); + return StandardCharsets.US_ASCII; } void setUnknown2(short unknown2) { diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hdgf/chunks/ChunkHeaderV6.java b/poi-scratchpad/src/main/java/org/apache/poi/hdgf/chunks/ChunkHeaderV6.java index 81bbe1ba14..9029b47880 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hdgf/chunks/ChunkHeaderV6.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hdgf/chunks/ChunkHeaderV6.java @@ -18,6 +18,7 @@ package org.apache.poi.hdgf.chunks; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; /** * A chunk header from v6 @@ -64,7 +65,7 @@ public class ChunkHeaderV6 extends ChunkHeader { @Override public Charset getChunkCharset() { - return Charset.forName("ASCII"); + return StandardCharsets.US_ASCII; } void setUnknown2(short unknown2) { diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/MessageSubmissionChunk.java b/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/MessageSubmissionChunk.java index f1ef43c766..482f8a941b 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/MessageSubmissionChunk.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/MessageSubmissionChunk.java @@ -20,6 +20,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.Calendar; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -62,7 +63,7 @@ public class MessageSubmissionChunk extends Chunk { public void readValue(InputStream value) throws IOException { // Stored in the file as us-ascii byte[] data = IOUtils.toByteArray(value); - rawId = new String(data, Charset.forName("ASCII")); + rawId = new String(data, StandardCharsets.US_ASCII); // Now process the date String[] parts = rawId.split(";"); @@ -112,7 +113,7 @@ public class MessageSubmissionChunk extends Chunk { @Override public void writeValue(OutputStream out) throws IOException { - byte[] data = rawId.getBytes(Charset.forName("ASCII")); + final byte[] data = rawId.getBytes(StandardCharsets.US_ASCII); out.write(data); } |