fix unicode decomposition (bugs 3313 and 3498):

* src/support/docstring.{cpp,h}:
	- rename normalize_kc to normalize_c and use normalization form C (instead of KC)

* src/callback.cpp:
* src/Trans.cpp:
* src/frontends/qt4/GuiClipboard.cpp:
* src/frontends/qt4/GuiSelection.cpp:
* lib/lyx2lyx/lyx_1_5.py:
	- use normalization forms C and D instead of KC and KD.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18991 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2007-07-05 14:45:00 +00:00
parent 180c6ac05f
commit 7562340249
7 changed files with 13 additions and 13 deletions

View File

@ -921,7 +921,7 @@ def _convert_accent(accent, accented_char):
return ''
a = accent_map.get(type)
if a:
return unicodedata.normalize("NFKC", "%s%s" % (char, a))
return unicodedata.normalize("NFC", "%s%s" % (char, a))
return ''
@ -1027,9 +1027,9 @@ def revert_accent(document):
# because we never use u'xxx' for string literals, but 'xxx'.
# Therefore we may have to try two times to normalize the data.
try:
document.body[i] = unicodedata.normalize("NFKD", document.body[i])
document.body[i] = unicodedata.normalize("NFD", document.body[i])
except TypeError:
document.body[i] = unicodedata.normalize("NFKD", unicode(document.body[i], 'utf-8'))
document.body[i] = unicodedata.normalize("NFD", unicode(document.body[i], 'utf-8'))
# Replace accented characters with InsetLaTeXAccent
# Do not convert characters that can be represented in the chosen
@ -1086,7 +1086,7 @@ def revert_accent(document):
accented_char = inverse_accented_map[accented_char]
accent = document.body[i][j]
try:
dummy = unicodedata.normalize("NFKC", accented_char + accent).encode(encoding_stack[-1])
dummy = unicodedata.normalize("NFC", accented_char + accent).encode(encoding_stack[-1])
except UnicodeEncodeError:
# Insert the rest of the line as new line
if j < len(document.body[i]) - 1:
@ -1101,7 +1101,7 @@ def revert_accent(document):
break
# Normalize to "Normal form C" (NFC, pre-composed characters) again
for i in range(numberoflines):
document.body[i] = unicodedata.normalize("NFKC", document.body[i])
document.body[i] = unicodedata.normalize("NFC", document.body[i])
def normalize_font_whitespace_259(document):

View File

@ -124,7 +124,7 @@ static docstring const doAccent(docstring const & s, tex_accent accent)
<< lyx_accent_table[accent].name << '.' << std::endl;
os << s.substr(1);
}
return normalize_kc(os.str());
return normalize_c(os.str());
}

View File

@ -409,7 +409,7 @@ docstring const getContentsOfPlaintextFile(BufferView * bv, string const & f,
file_content = from_local8bit(tmpstr);
}
return normalize_kc(file_content);
return normalize_c(file_content);
}

View File

@ -62,7 +62,7 @@ docstring const GuiClipboard::getAsText() const
{
// text data from other applications
QString const str = qApp->clipboard()->text(QClipboard::Clipboard)
.normalized(QString::NormalizationForm_KC);
.normalized(QString::NormalizationForm_C);
LYXERR(Debug::ACTION) << "GuiClipboard::getAsText(): `"
<< fromqstr(str) << "'" << endl;
if (str.isNull())

View File

@ -59,7 +59,7 @@ void GuiSelection::haveSelection(bool own)
docstring const GuiSelection::get() const
{
QString const str = qApp->clipboard()->text(QClipboard::Selection)
.normalized(QString::NormalizationForm_KC);
.normalized(QString::NormalizationForm_C);
LYXERR(Debug::ACTION) << "GuiSelection::get: " << fromqstr(str)
<< endl;
if (str.isNull())

View File

@ -140,9 +140,9 @@ std::string const to_filesystem8bit(docstring const & s)
}
docstring const normalize_kc(docstring const & s)
docstring const normalize_c(docstring const & s)
{
return qstring_to_ucs4(toqstr(s).normalized(QString::NormalizationForm_KC));
return qstring_to_ucs4(toqstr(s).normalized(QString::NormalizationForm_C));
}

View File

@ -62,8 +62,8 @@ docstring const from_filesystem8bit(std::string const & s);
/// convert \p s from ucs4 to the encoding of the file system.
std::string const to_filesystem8bit(docstring const & s);
/// normalize \p s to precomposed form kc
docstring const normalize_kc(docstring const & s);
/// normalize \p s to precomposed form c
docstring const normalize_c(docstring const & s);
/// Compare a docstring with a C string of ASCII characters
bool operator==(lyx::docstring const &, char const *);