in reply to Re^3: Converting a passage of Spanish into hyphens and spaces
in thread Converting a passage of Spanish into hyphens and spaces

I've just tried the Unicode one again and this time I got it to work. I don't know what I did differently in terms of my typing in your code plus the file name.

Recuerdo igual que si fuera hoy el día que llegué. Había hecho el viaje en tren con otros cinco compañeros novatos, y al bajar en la estación fuimos al hotel Condal, donde habíamos reservado habitaciones.

-------- ----- --- -- ----- --- -- -í- --- -----é. ---í- ----- -- ----- -- ---- --- ----- ----- -----ñ---- -------, - -- ----- -- -- ------ó- ------ -- ----- ------, ----- ---í---- --------- ------------.

As you can see there's still the letters with accents but if that can't be changed no worries and thank you very much for what you've done.

  • Comment on Re^4: Converting a passage of Spanish into hyphens and spaces

Replies are listed 'Best First'.
Re^5: Converting a passage of Spanish into hyphens and spaces
by shmem (Chancellor) on Sep 13, 2015 at 15:23 UTC
    As you can see there's still the letters with accents

    Extend your character class to have these translated, too:

    [[:alpha:]áéíóúñü]
    perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
      Thanks. Perl is great and I didn't know anything about it before yesterday.
Re^5: Converting a passage of Spanish into hyphens and spaces
by hippo (Archbishop) on Sep 13, 2015 at 15:28 UTC

    If the encoding is utf-8 rather than iso8859-1 then you can use the XPosixAlpha class like this:

    $ echo habíamos reservado habitaciones. | perl -CIO -pe 's/\p{XPosixAl +pha}/-/g;' -------- --------- ------------.
      Cheers I will look into that.