修复破解的UTF8编码(Fixing Broken UTF8 encoding)
我正在修复一些坏的UTF8编码。 我目前使用的是PHP 5和MySQL
在我的数据库中,我有一些不好的编码实例打印如下:î
- 数据库整理是utf8_general_ci
- PHP正在使用正确的UTF8标题
- Notepad ++设置为使用没有BOM的UTF8
- 数据库管理在phpMyAdmin中处理
- 并非所有重音字符都被打破
我需要的是一些功能,将帮助我将î,ÃÂ,ü¼和其他类似的实例映射到适当的重音UTF8字符。
I am in the process of fixing some bad UTF8 encoding. I am currently using PHP 5 and MySQL
In my database I have a few instances of bad encodings that print like: î
- The database collation is utf8_general_ci
- PHP is using a proper UTF8 header
- Notepad++ is set to use UTF8 without BOM
- database management is handled in phpMyAdmin
- not all cases of accented characters are broken
What I need is some sort of function that will help me map the instances of î, ÃÂ, ü and others like it to their proper accented UTF8 characters.
原文:https://stackoverflow.com/questions/1344692
最满意答案
下划线和光标代表Listbox项目的不同属性 -
下划线标记(它是Listbox的默认活动
activestyle
属性)显示活动项目。光标用于(a)选定的项目。
默认情况下,Tab键在此上下文中交替显示“活动”状态,因此它不会影响游标。
要更改光标位置,我们需要将活动项目设置为(a)所选项目。 我通过将Tab键绑定到执行此额外manouver的lambda函数来完成此操作:
l1.bind('<Tab>', lambda e: l2.select_set(l2.index(ACTIVE))) l2.bind('<Tab>', lambda e: l1.select_set(l1.index(ACTIVE)))
活动索引作为参数提供给相应的
select_set()
,然后将光标移动到下划线项目上。注:我认为对于更一般的情况,事件
e
应该用于拾取活动项目,而不是直接引用列表框。 但是,这似乎适用于2个列表框。The underscore and cursor represent different attributes of Listbox items -
The underscore marking, which is the default
activestyle
attribute of a Listbox, shows the active item.The cursor is for (a) selected item(s).
The Tab key, by default, alternates the "active" state in this context, so it does not affect the cursor.
To change the cursor position, we need to set the active item to be the (a) selected item as well. I've done so by binding the Tab key to lambda functions that perform this additional manouver:
l1.bind('<Tab>', lambda e: l2.select_set(l2.index(ACTIVE))) l2.bind('<Tab>', lambda e: l1.select_set(l1.index(ACTIVE)))
The active index is given as an argument to the appropriate
select_set()
, which then moves the cursor over the underscored item.Note: I think that for a more general case, the event
e
should be used to pick up the active item, rather than referring to the Listboxes directly. However, this seems to work fine for 2 listboxes.
相关问答
更多-
Tkinter中的按钮命令(Button commands in Tkinter)[2022-12-24]
command期望函数名称不带()和参数。 错误: command=player.do_action(action, **action.kwargs) 这样就可以分配给player.do_action()返回的command值,但是这个函数返回None 你必须使用lambda函数 command=lambda:player.do_action(action, **action.kwargs) 但也许你还需要lambda参数,因为你在for循环中创建它。 command=lambda act=action ... -
您可以将selectbackground添加到insert()循环中: for i, c in enumerate(color_palette): _col_pick.insert(tk.END, c) _col_pick.itemconfig(i, {'bg':c, 'selectbackground':c}) 这会将选择的背景设置为相同的颜色。 You can add selectbackground to your insert() loop: for i, c in enumera ...
-
Tkinter工作吗?(Does Tkinter work?)[2022-02-09]
运行tkinter._test() 。 注意括号。 Run tkinter._test(). Note the parenthesis. -
下划线和光标代表Listbox项目的不同属性 - 下划线标记(它是Listbox的默认活动activestyle属性)显示活动项目。 光标用于(a)选定的项目。 默认情况下,Tab键在此上下文中交替显示“活动”状态,因此它不会影响游标。 要更改光标位置,我们需要将活动项目设置为(a)所选项目。 我通过将Tab键绑定到执行此额外manouver的lambda函数来完成此操作: l1.bind('
', lambda e: l2.select_set(l2.index(ACTIVE))) l2.bind ... -
当Entry获得焦点时,可以使用bind来运行函数。 txtbox2.bind('
', fn_jump) 要使用bind,您调用的函数必须接受一个事件参数,因此将该定义更改为 def fn_jump(event=None): You can do that by using bind to run a function when the Entry gets focus. txtbox2.bind(' ', fn_jump) To use bind, the func ... -
正如在帖子“Tkinter主窗口焦点”中提到的那样,可以将焦点强制到主窗口。 解决方法 - 将一个调用添加到after()到focus_force() 。 from tkinter import * main = Tk() def pressButton(): main.destroy() End=Button(main,text='Finished',width=15,command=pressButton).grid() # call the focus_force() after the w ...
-
一个项目在您点击它之后变为活动状态 - 这意味着您的ListboxSelect方法返回后。 所以,你打印出这个点击之前所有活动的内容(通常意思是你上次点击的内容)。 另外,考虑到你多次提及“选择”,我想你想要的是选定的值,而不是活动的 ,所以你应该问这个问题。 对于带有selectmode=SINGLE或BROWSE (默认,你有什么)列表框的列表框,你可以修复这两个。 只需改变这一点: mylistbox.get(ACTIVE) 至: mylistbox.get(mylistbox.curselecti ...
-
Tkinter小部件可以占用多个网格单元,但您需要使用columnspan和rowspan关键字.grid管理布局.grid 。 例如,要获得布局: -------------------------------------------- | Button1 | Button2 | | -------------------------------- Button3 | | Label1 | Label2 | Label3 | ...
-
找到一些时间提供工作实例;) import Tkinter import tkMessageBox root = Tkinter.Tk() but1 = Tkinter.Button(root, text ="Button 1") but1.pack() butNoFocus = Tkinter.Button(root, text ="Button no focus", takefocus = 0) butNoFocus.pack() but2 = Tkinter.Button(root, text ...
-
光标在Tkinter中移动时生成事件[重复](Generating an event when the cursor moves in Tkinter [duplicate])[2022-05-05]
本身没有任何内置功能,但如果您愿意发挥创意,那么您想要做的就是可能。 在它的核心,文本小部件是一个tcl命令,每当文本小部件发生某些事情时都会调用此命令:插入文本,删除文本,光标更改等.tcl的本质是我们可以用我们自己的命令替换此命令命令。 由于我们可以做到这一点,我们可以检测到某些变化,并在之前或之后调用我们自己的函数。 听起来很复杂,而且确实很复杂。 从积极的方面来说,一旦你有它工作,它是万无一失的,这意味着你不必做任何自定义绑定。 要查看完整的工作示例,请参阅绑定到光标移动的问题的答案 不会更改INS ...