[forge-issues] [JBoss JIRA] (FORGE-895) Shell crops Strings with UTF-8 charaters
Florian Hirsch (JIRA)
jira-events at lists.jboss.org
Fri May 10 13:26:53 EDT 2013
Florian Hirsch created FORGE-895:
------------------------------------
Summary: Shell crops Strings with UTF-8 charaters
Key: FORGE-895
URL: https://issues.jboss.org/browse/FORGE-895
Project: Forge
Issue Type: Bug
Components: UI - Shell
Affects Versions: 1.2.3.Final
Reporter: Florian Hirsch
Priority: Minor
when I try to print some UTF-8 characters in the shell the end of the line is cropped. E.g.
{code}
shell.print("\u2501 Hello World");
{code}
results in
{code}
━ Hello Wor
{code}
Looks like the org.jboss.forge.shell.buffers.JLineScreenBuffer is calculating the BufferSize wrong:
{code}
public synchronized void write(String s) {
if (bufferSize + s.length() >= maxBufferSize)
{
flushBuffer();
write(s);
}
buffer.put(s.getBytes());
bufferSize += s.length();
_flush();
}
{code}
s.length() is returning the size of the used Characters, not the Size of the used Bytes. Could be replaced by s.getBytes("UTF-8").length or e.g. [this calculation method|http://stackoverflow.com/questions/8511490/calculating-length-in-utf-8-of-java-string-without-actually-encoding-it/8512877#8512877]
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the forge-issues
mailing list