Skip to content

enables StringStreamSource.getInputStream() return a byte array in given charset #486

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 16, 2015

Conversation

bluejoe2008
Copy link
Contributor

When users attempt to parse a 'UTF-8'-encoded BPMN file (while the locale charset is not set as 'UTF-8') using following codes:

    String fileContent = IOUtils.readStringAndClose(new InputStreamReader(new FileInputStream(modelFile), "utf-8"), (int) modelFile.length());
    BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(new StringStreamSource(fileContent), false, false); 

the result bpmnModel is wrong because properties of all model elements are parsed in locale charset, Chinese 'gb2312' for example.

I think this error is caused by that StringStreamSource.getInputStream() returns a byte array stream using locale charset encoding, and that is why I add a new two-arguments constructor for StringStreamSource class.

Now, codes could be written as below:

    BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(new StringStreamSource(fileContent, "utf-8"), false, false); 

tijsrademakers added a commit that referenced this pull request Jan 16, 2015
enables StringStreamSource.getInputStream() return a byte array in given charset
@tijsrademakers tijsrademakers merged commit 4a6a211 into Activiti:master Jan 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants