lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

a locale-independent search/replace?


From: Joe Neeman
Subject: a locale-independent search/replace?
Date: Sun, 25 Nov 2007 09:29:25 +1100
User-agent: KMail/1.9.7

Does anyone know how to write a simple search and replace for a UTF-8 string 
that works regardless of the current locale?

In order to fix bug 499, I tried to write a simple function that replaces all 
whitespace by spaces. My first attempt was pretty stupid -- I forgot that the 
string was in utf-8. This caused problems for "uiop" on the bug list. So I 
wrote a utf-8 version using mbrtowc and iswspace, but this fails if I set 
LC_ALL=ASCII because mbrtowc then thinks that all accented characters are 
invalid utf-8 sequences.

I suppose I could iconv to wchar_t, search, replace and iconv back but it 
seems that we don't currently depend on iconv and introducing a dependency 
seems like overkill. Am I missing something simple?

Joe




reply via email to

[Prev in Thread] Current Thread [Next in Thread]