我正在尝试保存iPhone应用程序中的评论,这些评论可能现在很可能会包含表情符号.无论我做什么,我都无法将表情符号保存到MySQL数据库......常量Unicode错误.
我一直收到的错误是:
Incorrect string value: '\xF0\x9F\x97\xBC \xF0...' for column 'body' at row 1
Run Code Online (Sandbox Code Playgroud)
我传入数据库的字符串是:
test_txt = u"Emoji - \U0001f5fc \U0001f60c \U0001f47b ...".encode('utf-8')
Run Code Online (Sandbox Code Playgroud)
更新:这是我正在使用的模型:
class ItemComment(db.Model):
item = db.ForeignKey(Item)
user = db.ForeignKey(Profile)
body = db.CharField(max_length=255, blank=True, null=True)
active = db.BooleanField(default=True)
date_added = db.DateTimeField(auto_now_add=True)
def __unicode__(self):
return "%s" % (self.item)
Run Code Online (Sandbox Code Playgroud)
奇怪的是,如果我尝试将其传递给我在MySQL中创建的字段而不是Django models.py它可以正常工作.但是只要我在Django模型中注册该字段就会死掉.是否有其他方式来存储这些?
任何想法都会很棒.
我不能再坚持这个......
更新2:使用以下UPDATE语句在终端中跟踪它(注意U0001f5fc)
UPDATE 'table' SET 'body' = '', WHERE 'table'.'id' = 1 ; args=(u'\U0001f5fc')
Run Code Online (Sandbox Code Playgroud)
使用硬核,因为我可以传递值:
force_unicode(smart_str(value), encoding='utf-8', strings_only=False, errors='ignore') …
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建聊天界面,就像Line app
你可以写表情符号的地方一样.我尝试了几种不同的方法:
关于有效方法的任何建议?
示例输入字符串:test:)test:)test:) :) test:p test
通缉输出字符串:test :) test :) test :) :) test :p test
正如您在上面的示例中所看到的,我想解析字符串并生成一个输出字符串,并在所有预定义的笑脸代码周围添加空格.
我试图通过几个循环来做到这一点,但最终它没有像预期的那样100%工作,而且在大型文档上速度非常慢.
所以我想知道用PHP进行这种解析最好和最有效的方法是什么?
就像标题所说的那样.我想知道给定的java String是否包含表情符号.
我无法使用,Character.UnicodeBlock.of(char) == Character.UnicodeBlock.EMOTICONS
因为这需要API级别19.
我发现这个代码适用于iOS,但它并不适用,因为它看起来像java和objective-c以不同的方式处理代理对.
我看过的文件告诉我:
A char value, therefore, represents Basic Multilingual Plane (BMP) code points, including the surrogate code points, or code units of the UTF-16 encoding
Run Code Online (Sandbox Code Playgroud)
我不太清楚这意味着什么.这仅仅意味着他们还将BMP点作为他们的第一个数字吗?
根据维基百科,表情符号集位于0x1f600和0x1f64f之间,但我不知道如何检查char是否在该范围内.
我曾希望这样的东西可行,但事实并非如此
if (0x1f600 <= a && a <= 0x1f64f)
{
Print.d("Unicode", "groovy!");
}
Run Code Online (Sandbox Code Playgroud)
那么我该怎么做呢?
我是git和GitHub的新手.我在Windows 7 64位上使用GitHub for Windows程序.我不喜欢的是,当我创建一个新的本地存储库时,.gitattributes
添加文件的初始更改会被赋予一个包含表情符号的提交消息(看似随机选择).
以下是此问题的屏幕截图:http
://i.stack.imgur.com/sXVkv.gif上例中的表情符号为"confetti ball":http://i.stack.imgur.com/ePYdv巴纽
我该如何防止这个表情符号?或者至少,我如何防止自动提交初始更改,以便我有机会编辑提交消息以删除表情符号?
虽然我更喜欢与程序的GUI进行交互,但我对命令行有足够的练习,如果这个问题的修复需要使用它,我对此感到很满意.
对此的任何帮助将非常感激.
我试图在elasticsearch中搜索包含文本的表情符号/表情符号.早些时候,我在ES中插入了推文.现在我想搜索微笑或悲伤面孔相关的推文.我尝试了以下内容
1)使用相当于微笑的unicode值,但没有用.没有返回任何结果.
GET /myindex/twitter_stream/_search
{
"query": {
"match": {
"text": "\u1f603"
}
}
}
Run Code Online (Sandbox Code Playgroud)
如何在elasticsearch中设置表情符号搜索?是的,我必须在输入弹性搜索之前对原始推文进行编码?什么是查询?有经验的方法吗?谢谢.
在RichtTextBox中,我想用表情:D
符号图像自动替换表情符号字符串(例如).我到目前为止工作,除了当我在现有的单词/字符串之间写出表情符号字符串时,图像会在行尾插入.
例如:
hello (inserting :D here) this is a message
结果:
hello this is a message ?
<< image
另一个(微小的)问题是插入后的插入位置在插入之前设置.
这就是我已经得到的:
public class Emoticon
{
public Emoticon(string key, Bitmap bitmap)
{
Key = key;
Bitmap = bitmap;
BitmapImage = bitmap.ToBitmapImage();
}
public string Key { get; }
public Bitmap Bitmap { get; }
public BitmapImage BitmapImage { get; }
}
public class EmoticonRichTextBox : RichTextBox
{
private readonly List<Emoticon> _emoticons;
public EmoticonRichTextBox()
{
_emoticons = new List<Emoticon>
{ …
Run Code Online (Sandbox Code Playgroud) 我试图在python字符串中搜索表情符号.所以我有,例如,
em_test = ['\U0001f680']
print(em_test)
['']
test = 'This is a test string '
if any(x in test for x in em_test):
print ("yes, the emoticon is there")
else:
print ("no, the emoticon is not there")
yes, the emoticon is there
Run Code Online (Sandbox Code Playgroud)
如果在中搜索em_test
'这是一个测试字符串'
我实际上可以找到它.
所以我制作了一个csv文件,其中包含我想用unicode定义的所有表情符号.CSV看起来像这样:
\ U0001F600
\ U0001F601
\ U0001F602
\ U0001F923
当我导入并打印它时,我不会获得表情符号,而只是文本表示:
['\\U0001F600',
'\\U0001F601',
'\\U0001F602',
'\\U0001F923',
...
]
Run Code Online (Sandbox Code Playgroud)
因此我不能用它在另一个字符串中搜索这些表情符号...我知道双反斜杠\只表示单斜杠但不知何故unicode读者不能得到它...我不知道我是什么我失踪了.
有什么建议?
我正在使用 tm 包来清理 Twitter 语料库。但是,该软件包无法清理表情符号。
\n\n这是复制的代码:
\n\nJuly4th_clean <- tm_map(July4th_clean, content_transformer(tolower))\nError in FUN(content(x), ...) : invalid input 'RT ElleJohnson Love of country is encircling the globes \xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd july4thweekend July4th FourthOfJuly IndependenceDay NotAvailableOnIn' in 'utf8towcs'\n
Run Code Online (Sandbox Code Playgroud)\n\n有人可以指出我使用 tm 包删除表情符号的正确方向吗?
\n\n谢谢你,
\n\n路易斯
\n我在 Python Pandas 中有 DataFrame,如下所示:
sentence
------------
I like it
+1
One :-) :)
hah
Run Code Online (Sandbox Code Playgroud)
我需要仅选择包含表情符号或表情符号的行,因此我需要如下所示的内容:
sentence
------------
+1
One :-) :)
Run Code Online (Sandbox Code Playgroud)
我怎样才能在Python中做到这一点?