Author: mordante
Date: Tue May 12 21:58:37 2009
New Revision: 35608
URL: http://svn.gna.org/viewcvs/wesnoth?rev=35608&view=rev
Log:
Fixed UTF-8 handling in the password textbox.
A multi-character in the textbox had its length determined with the
number of characters instead of number of UTF-8 glyphs.
Modified:
branches/1.6/changelog
branches/1.6/players_changelog
branches/1.6/src/gui/widgets/password_box.cpp
Modified: branches/1.6/changelog
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/1.6/changelog?rev=35608&r1=35607&r2=35608&view=diff
==============================================================================
--- branches/1.6/changelog (original)
+++ branches/1.6/changelog Tue May 12 21:58:37 2009
@@ -1,6 +1,8 @@
Version 1.6.2+svn:
* Language and i18n:
* Updated translations: Chinese (Traditional), Russian, Slovak
+ * User interface:
+ * Fixed an multi-character UTF-8 handling bug in the password textbox
Version 1.6.2:
* Campaigns:
Modified: branches/1.6/players_changelog
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/1.6/players_changelog?rev=35608&r1=35607&r2=35608&view=diff
==============================================================================
--- branches/1.6/players_changelog (original)
+++ branches/1.6/players_changelog Tue May 12 21:58:37 2009
@@ -6,6 +6,8 @@
* Language and translations
* Updated translations: Chinese (Traditional), Russian, Slovak.
+ * User interface
+ * Fixed the MP password textbox handling of special characters.
Version 1.6.2:
* Campaigns
Modified: branches/1.6/src/gui/widgets/password_box.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/1.6/src/gui/widgets/password_box.cpp?rev=35608&r1=35607&r2=35608&view=diff
==============================================================================
--- branches/1.6/src/gui/widgets/password_box.cpp (original)
+++ branches/1.6/src/gui/widgets/password_box.cpp Tue May 12 21:58:37 2009
@@ -16,13 +16,23 @@
#define GETTEXT_DOMAIN "wesnoth-lib"
#include "gui/widgets/password_box.hpp"
+#include "serialization/string_utils.hpp"
namespace gui2 {
+
+namespace {
+
+size_t get_text_length(const std::string& str)
+{
+ return utils::string_to_wstring(str).size();
+}
+
+} // namespace
void tpassword_box::set_value(const std::string& text) {
ttext_box::set_value(text);
real_value_ = get_value();
- ttext_box::set_value(std::string(real_value_.size(), '*'));
+ ttext_box::set_value(std::string(get_text_length(real_value_), '*'));
}
void tpassword_box::insert_char(const Uint16 unicode) {
@@ -62,7 +72,7 @@
handled = true;
if(get_selection_length() != 0) {
delete_selection();
- } else if (get_selection_start() < text().size()) {
+ } else if (get_selection_start() < get_text_length(text())) {
delete_char(false);
}
@@ -96,7 +106,7 @@
// Get the input back and make ttext_box forget it
real_value_ = get_value();
- ttext_box::set_value(std::string(real_value_.size(), '*'));
+ ttext_box::set_value(std::string(get_text_length(real_value_), '*'));
// See above
set_selection_start(selection_start);
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits