From f3551de1de4aae1e9e21c444690546a6e56c9d30 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Fri, 18 Mar 2022 09:44:29 -0500 Subject: [PATCH] Correcting Spanish accented characters, when they come from the terminal output (e.g. via OSSubprocess). --- repository/Grafoscopio-Utils/String.extension.st | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/repository/Grafoscopio-Utils/String.extension.st b/repository/Grafoscopio-Utils/String.extension.st index 535e51a..2e73149 100644 --- a/repository/Grafoscopio-Utils/String.extension.st +++ b/repository/Grafoscopio-Utils/String.extension.st @@ -1,5 +1,18 @@ Extension { #name : #String } +{ #category : #'*Grafoscopio-Utils' } +String >> accentedCharactersCorrection [ + | modified corrections | + corrections := { + 'ó' -> 'ó' . 'ú' -> 'ú' . 'ñ' -> 'ñ' . + 'í' -> 'í' . 'á' -> 'á' . 'é' -> 'é' } asDictionary. + modified := self copy. + corrections keysAndValuesDo: [ :k :v | + modified := modified copyReplaceAll: k with: v + ]. + ^ modified +] + { #category : #'*Grafoscopio-Utils' } String >> asCapitalizedPhrase [ "I convert phrases like 'THIS IS A PHRASE' into 'This is a Phrase'."