[Sugar-devel] new-patch

Ariel Calzada ariel.calzada at gmail.com
Mon Apr 16 12:07:12 EDT 2012


>From b330bc11f58b82eaecbbd41224077da381e62408 Mon Sep 17 00:00:00 2001
From: Ariel Calzada <ariel at acivitycentral.com>
Date: Mon, 16 Apr 2012 11:02:19 -0500
Subject: [PATCH] =?UTF-8?q?Added=20decode=20utf-8=20and=20normalize=20string?=
 =?UTF-8?q?=20for=20fixing=20bug=20in=20nick=20that=20don't=20display=20well?=
 =?UTF-8?q?=20the=20nicknames=20that=20have=20accents=20like=20=C3=A1,=C3=A9?=
 =?UTF-8?q?,=C3=AD,=C3=B1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 player.py |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/player.py b/player.py
index 5e9e8db..a6636dc 100644
--- a/player.py
+++ b/player.py
@@ -8,17 +8,17 @@
 #
 # Copyright (C) 2007  Joshua Minor
 # This file is part of Maze.activity
-# 
+#
 #     Maze.activity is free software: you can redistribute it and/or modify
 #     it under the terms of the GNU General Public License as published by
 #     the Free Software Foundation, either version 3 of the License, or
 #     (at your option) any later version.
-# 
+#
 #     Maze.activity is distributed in the hope that it will be useful,
 #     but WITHOUT ANY WARRANTY; without even the implied warranty of
 #     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 #     GNU General Public License for more details.
-# 
+#
 #     You should have received a copy of the GNU General Public License
 #     along with Maze.activity.  If not, see <http://www.gnu.org/licenses/>.
 
@@ -29,14 +29,16 @@ from sugar.graphics.xocolor import XoColor
 import pygame
 import re
 import os
+import unicodedata
 
 
 class Player:
     def __init__(self, buddy, shape='circle'):
         self.buddy = buddy
-        self.nick = buddy.props.nick.decode("utf-8")
+        name = buddy.props.nick.decode('utf-8')
+        self.nick = unicodedata.normalize('NFC',name)
         colors = buddy.props.color.split(",")
-        
+
         def string2Color(str):
             return (int(str[1:3], 16), int(str[3:5], 16), int(str[5:7], 16))
         self.colors = map(string2Color, colors)
@@ -70,7 +72,7 @@ class Player:
         self.position = (1, 1)
         self.previous = (1, 1)
         self.elapsed = None
-    
+
     def animate(self, maze):
         # if the player finished the maze, then don't move
         if maze.map[self.position[0]][self.position[1]] == maze.GOAL:
@@ -83,7 +85,7 @@ class Player:
         else:
             self.direction = (0, 0)
         return self.position
-    
+
     def move(self, direction, maze):
         """Move the player in a given direction (deltax,deltay)"""
         newposition = (self.position[0] + direction[0], self.position[1] + direction[1])
@@ -111,7 +113,7 @@ class Player:
                 directions.remove(d)
         # is there only one possible direction?
         if len(directions) == 1:
-       	    self.direction = directions[0]
+            self.direction = directions[0]
         else:
             self.direction = (0, 0)
 
-- 
1.7.5.4



More information about the Sugar-devel mailing list