Skip to main content

Posts

Showing posts from August, 2015

command line mail with accent

Send characters like é è à in a command line mail I run CentOS 6, and made my first try with the "bsd-mailx" "mail" command line.

#!/bin/bash export LANG=fr_FR.UTF-8 export LC_ALL=fr_FR.UTF-8 echo "Tâches du $( date +"%a %d %b %Y" -d "+1days" )" | mail -s "$( date +"%a %d %b %Y" -d "+1days" )" toto@rktmb.org
When current month is "August", "Août" in French, it is just the big mess: characters are not encoded!

I tried with

mail -a "Content-Type: text/plain; charset=UTF-8"
But it displayed right for the body, the subject was screwed yet

Then I switched to "mailx":

# yum remove bsd-mailx # yum install mailx

I tried with

mail -S sendcharsets=utf-8,iso-8859-1
And this works!

antlr java parser tree tokens

Use antlr to get a tree view of a Java piece of code
Let this loop be (save it under ~/workdir/LoopOne.java):
class LoopOne { public static void main(String[] args) { float x = Float.parseFloat(args[0]); while ( 0 - x <= 0){ x = x - 1; } } }
If you want to get it parsed, you can use Antlr (http://www.antlr.org/)

cd ~/workdir
curl -O http://www.antlr.org/download/antlr-4.5-complete.jar curl -O https://raw.githubusercontent.com/antlr/grammars-v4/master/java8/Java8.g4
In ".bashrc":
export CLASSPATH=".:/home/mrakotomandimby/workdir/antlr-4.5-complete.jar:$CLASSPATH" alias antlr4='java -Xmx500M -cp ".:/home/mrakotomandimby/workdir/antlr-4.5-complete.jar:$CLASSPATH" org.antlr.v4.Tool' alias grun='java org.antlr.v4.runtime.misc.TestRig'
antlr4 Java8.g4 javac LoopOne.java Java8*.java grun Java8 compilationUnit -tree LoopOne.java grun Java8 compilationUnit -gui LoopOne.java