#!/usr/bin/perl

require 5.004;
use locale;

use POSIX qw(locale_h);

setlocale (LC_TYPE, 'ro_RO.UTF-8');

binmode(STDOUT, ":utf8");
binmode(STDIN, ":utf8");

while (defined($line = <STDIN>))
{
	next if ( ! $line ) ;

	$line =~ s/([\w]+)/\u\L$1/g;
	#$line =~ s/([\w]+)/[$1]/g;

	do {
		$ol = $line ;
		# for some weird and unknown reason lowercase(Ș) isn't computed
		$line =~ s/ (De|Din|Spre|La|Si|Pe|Și|Prin|Dinspre|Cu|Lui|Cel) / \l$1 /g;
	} until ( $ol =~ $line ) ;

	print $line ;

}

