Skip to content

Add UTF_8_BOM (Caption UTF-8-BOM) to StandardEncodings Enumeration in Mendix Studio Pro #170

@atennapel

Description

@atennapel

This issue was reported by Marcin Nowak from Jabil

Please add UTF_8_BOM option for Encoding. This will fix issue generating CSV files in Polish Language. It can be done in very simple way:

  1. Add UTF_8_BOM (Caption UTF-8-BOM) to StandardEncodings Enumeration in Mendix Studio Pro
  2. Add this to StringUtils.java from communitycommons:
public static void stringToFileUtf8Bom(IContext context,
String value,
FileDocument destination) throws IOException {
if (destination == null) {
throw new IllegalArgumentException("Destination file is null");
}
if (value == null) {
throw new IllegalArgumentException("Value to write is null");
}

// Prepend BOM as U+FEFF, then write with standard UTF-8
stringToFile(context, "\uFEFF" + value, destination, StandardCharsets.UTF_8);
}
  1. Replace function public java.lang.Boolean executeAction() throws Exception in StringToFile.java from communitycommons.actions:
public java.lang.Boolean executeAction() throws Exception
{
// BEGIN USER CODE
if (this.encoding == communitycommons.proxies.StandardEncodings.UTF_8_BOM) {
StringUtils.stringToFileUtf8Bom(getContext(), value, destination);
return true;
}

Charset charset = StandardCharsets.UTF_8;
if (this.encoding != null)
charset = Charset.forName(this.encoding.name().replace('_', '-'));
StringUtils.stringToFile(getContext(), value, destination, charset);
return true;
// END USER CODE
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions