diff --git a/platform/diff-impl/src/com/intellij/diff/tools/external/ExternalDiffToolUtil.java b/platform/diff-impl/src/com/intellij/diff/tools/external/ExternalDiffToolUtil.java index 2eccc8d703ed..936ee405660f 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/external/ExternalDiffToolUtil.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/external/ExternalDiffToolUtil.java @@ -129,7 +129,7 @@ public class ExternalDiffToolUtil { byte[] bytes = contentData.getBytes(charset); - byte[] bom = hasBom ? CharsetToolkit.getBom(charset) : null; + byte[] bom = hasBom ? CharsetToolkit.getPossibleBom(charset) : null; if (bom != null) { bytes = ArrayUtil.mergeArrays(bom, bytes); } diff --git a/platform/util/src/com/intellij/openapi/vfs/CharsetToolkit.java b/platform/util/src/com/intellij/openapi/vfs/CharsetToolkit.java index 178936acf6ec..b8f94ab9e12e 100644 --- a/platform/util/src/com/intellij/openapi/vfs/CharsetToolkit.java +++ b/platform/util/src/com/intellij/openapi/vfs/CharsetToolkit.java @@ -624,8 +624,12 @@ public class CharsetToolkit { return CHARSET_TO_MANDATORY_BOM.get(charset); } + /** + * @return BOM which can be associated with this charset, or null otherwise. + * Currently these are UTF-16xx, UTF-32xx and UTF-8. + */ @Nullable - public static byte[] getBom(@NotNull Charset charset) { + public static byte[] getPossibleBom(@NotNull Charset charset) { if (charset.equals(UTF8_CHARSET)) return UTF8_BOM; return CHARSET_TO_MANDATORY_BOM.get(charset); }