MessageBox仅显示一个字符

时间:2016-07-16 07:19:01

标签: python-3.x ctypes

为什么这只为标题和框内打印一个字符。我如何确保打印出来?

<!DOCTYPE html>
<html>
    <head>
        <!-- 1 -->
<link href="dropzone.css" type="text/css" rel="stylesheet" />
 
<!-- 2 -->
<script src="dropzone.min.js"></script>>
    </head>
    
<script type="text/javascript">
//NOTHING WORKS IN HERE
// The camelized version of the ID of the form element
Dropzone.options.myAwesomeDropzone = {
		  maxFilesize: 1, // Size in MB
		  addRemoveLinks: true,
		    removedfile: function(file) { 
		      var fileRef;
		      return (fileRef = file.previewElement) != null ? 
				      fileRef.parentNode.removeChild(file.previewElement) : void 0;
		    }
                };
</script>

 
<body>
<!-- 3 -->
<form action="upload.php" class="dropzone"></form>   

 </body> 
</html>

只有&#39;我&#39;得到印刷,只有&#39; t&#39;为标题打印,问题是什么?

1 个答案:

答案 0 :(得分:2)

如果你测试

ctypes.windll.user32.MessageBoxW(0, "info", "title", 3)

应该有&#34; info&#34;和&#34;标题&#34;。如果你测试

ctypes.windll.user32.MessageBoxA(0, "info".encode('ascii'), 
                                 "title".encode('ascii'), 3)

所以它似乎是某种文本编码问题。 UTF-16-le编码的字符串可能默认传递。

>>> 'info'.encode('utf-16-le')
b'i\x00n\x00f\x00o\x00'
>>> 'title'.encode('utf-16-le')
b't\x00i\x00t\x00l\x00e\x00'

由于MessageBoxA期望NULL终止C字符串,所以从头开始只考虑两个字符,即'i\0''t\0'