Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenquotes.git

Forces standard output encoding to UTF-8

AuthorDave Jarvis <email>
Date2023-02-20 12:48:08 GMT-0800
Commit39062c20262b2d8ff84f9beffc5c2f5b87eb70c8
Parentcd58010
src/main/java/com/whitemagicsoftware/keenquotes/app/KeenQuotes.java
import picocli.CommandLine;
-import java.io.IOException;
-import java.io.InputStream;
+import java.io.*;
+import java.nio.charset.Charset;
import java.util.Properties;
final var parser = new CommandLine( app.getSettings() );
parser.setColorScheme( createColourScheme() );
+
+ setStdoutEncoding( UTF_8 );
final var exitCode = parser.execute( args );
exit( exitCode );
}
+ }
+
+ @SuppressWarnings( "SameParameterValue" )
+ private static void setStdoutEncoding( final Charset cs ) {
+ final var fos = new FileOutputStream( FileDescriptor.out );
+ final var ps = new PrintStream( fos, true, cs );
+
+ System.setOut( ps );
}
}
src/test/resources/com/whitemagicsoftware/keenquotes/texts/unambiguous-2-pass.txt
I leave proofs to those who &apos;ve seen &apos;em;\n\nBut this I heard her say, and can&apos;t be wrong\n\nAnd all may think which way their judgments lean &apos;em,\n\n&lsquo;&apos;T is strange---the Hebrew noun which means &ldquo;I am,&rdquo;\n\nThe English always use to govern d--n.&rsquo;
+''E's got a 'ittle box 'n a big 'un,' she said, 'wit' th' 'ittle 'un 'bout 2'×6". An' no, y'ain't cryin' on th' "soap box" to me no mo, y'hear. 'Cause it 'tweren't ever a spec o' fun!' I says to my frien'.
+&lsquo;&apos;E&apos;s got a &apos;ittle box &apos;n a big &apos;un,&rsquo; she said, &lsquo;wit&rsquo; th&apos; &apos;ittle &apos;un 'bout 2&prime;×6&Prime;. An&apos; no, y&apos;ain&apos;t cryin&apos; on th&apos; &ldquo;soap box&rdquo; to me no mo, y&apos;hear. 'Cause it &apos;tweren&apos;t ever a spec o&apos; fun!&rsquo; I says to my frien&apos;.
+
"Jarvis, sir? Why, him as 'listed some years ago, and fought under\n\nSir Reginald.'
&ldquo;Jarvis, sir? Why, him as &lsquo;listed some years ago, and fought under\n\nSir Reginald.&rsquo;
Delta15 lines added, 2 lines removed, 13-line increase