Skip to content
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

strformat corrupt cyrillic symbols #1128

Closed
uujava opened this issue Oct 15, 2013 · 1 comment
Closed

strformat corrupt cyrillic symbols #1128

uujava opened this issue Oct 15, 2013 · 1 comment
Milestone

Comments

@uujava
Copy link

@uujava uujava commented Oct 15, 2013

puts Time.at(100).strftime('Процесс завершен за %S')
will puts garbage.
From the RubyDateFormatter code it looks like it does not set proper encoding when creating InputStreamReader and appending bytes to output.
Unable to attache the patch - copying it below:

Index: core/src/main/java/org/jruby/util/RubyDateFormatter.java
<+>UTF-8
===================================================================
--- core/src/main/java/org/jruby/util/RubyDateFormatter.java    (date 1381750123000)
+++ core/src/main/java/org/jruby/util/RubyDateFormatter.java    (date 1381841997000)
@@ -258,7 +258,7 @@
         }
 
         ByteArrayInputStream in = new ByteArrayInputStream(pattern.getUnsafeBytes(), pattern.getBegin(), pattern.getRealSize());
-        Reader reader = new InputStreamReader(in);
+        Reader reader = new InputStreamReader(in, pattern.getEncoding().getCharset());
         lexer.yyreset(reader);
 
         Token token;
@@ -549,9 +549,7 @@
             // reset formatter
             formatter = RubyTimeOutputFormatter.DEFAULT_FORMATTER;
 
-            for (int i = 0; i < output.length(); i++) {
-                toAppendTo.append(output.charAt(i));
-            }
+            toAppendTo.append(output.getBytes(toAppendTo.getEncoding().getCharset()));
         }
 
         RubyString str = context.runtime.newString(toAppendTo);
@headius headius closed this in bb5b52c Oct 21, 2013
@jlbfalcao
Copy link

@jlbfalcao jlbfalcao commented Oct 21, 2013

same problem with portuguese. Can't use 1.7.5 for this reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants