emoji.cr

💚 Emoji for Crystal
授权协议 MIT License
开发语言 JavaScript
所属分类 程序开发、 Emoji 表情相关
软件类型 开源软件
地区 不详
投 递 者 梁韬
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

emoji.cr

Crystal CI

Emoji library for Crystal. Inspired by Emoji for Python

Installation

As a dependency in shard.yml:

dependencies:
  emoji:
    github: veelenga/emoji.cr
    branch: master

Usage

require "emoji"

puts Emoji.emojize("I ❤ �� and ��")

Will print the following in console:

Also it is possible to remove all emoji from the string:

str = Emoji.emojize("Girl on ��")
Emoji.sanitize(str) #=> "Girl on "

Sanitizing is based on Emoji regex. There are two options available:

  • :simple emoji regex (default)
  • :generated emoji regex

Simple regex uses unicode ranges to find emojis and may give some incorrect results.Generated regex is quite big, but works correctly in 100% cases.However, it is much slower than a simple regex.

If you need more accuracy sanitizing emojis and don't care about performance, just use generated one:

Emoji.sanitize(str, regex: :generated)

Regex

require "emoji"

string = "String which contains all kinds of emoji:

- Singleton Emoji: (��)
- Textual singleton Emoji with Emoji variation: (▶️)
- Emoji with skin tone modifier: (����)
- Region flag: (����)
- Sub-Region flag: (��������������)
- Keycap sequence: (7️⃣)
- Sequence using ZWJ (zero width joiner): (��‍��‍��‍��)

"

string.scan(Emoji::GENERATED_EMOJI_REGEX) do |m|
  puts "`#{m[0]}` - #{m[0].size} code points"
end
`��` - 1 code points
`▶️` - 2 code points
`����` - 2 code points
`����` - 2 code points
`��������������` - 7 code points
`7️⃣` - 3 code points
`��‍��‍��‍��` - 7 code points

Binary

You may also compile and use emojize binary that just prints to console emojized string:

crystal build bin/emojize
./emojize It will boom: ��

Resources

Contributing

  1. Fork it ( https://github.com/veelenga/emoji.cr/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request
  • 坑爹的flutter正则; emoji过滤正则表达式:"[^\\u0020-\\u007E\\u00A0-\\u00BE\\u2E80-\\uA4CF\\uF900-\\uFAFF\\uFE30-\\uFE4F\\uFF00-\\uFFEF\\u0080-\\u009F\\u2000-\\u201f\r\n]" RegExp regexp=RegExp("[^\\u0020-\\u007E\\u0

  • mysql存储emoji表情报错的处理方法:更改编码为utf8mb4 uft-8编码可能2个字节、3个字节、4个字节,而MySql的uft-8只支持3字节的数据,而移动端的表情数据是4字节的字符。如果直接采用utf-8编码的数据库中插入表情数据,Java程序将报错: java.sql.SQLException: Incorrect string value: '\xF0\x9F\x92\x94'

相关阅读

相关文章

相关问答

相关文档