Skip to content
This repository

strformat corrupt cyrillic symbols #1128

Closed
uujava opened this Issue · 1 comment

2 participants

uujava Jorge Falcão
uujava

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);
Jorge Falcão

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
Something went wrong with that request. Please try again.