Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Unicode of smiley in scala

I am getting smilies as an input from the user.

val emojis="😃😜😍"

I want its unicode to store in DataBase. in my console it is printing like this

😃😜😍

may be question is unclear i want like this 😃 to \u263a;

like image 867
Govind Singh Avatar asked Mar 18 '23 22:03

Govind Singh


1 Answers

I think you're looking for U+263A. The best way to represent this in source code is with a Unicode escape sequence:

val smiley = "\u263a";

You then need to check that:

  • Your database is able to store it (check the type of your field, potentially collation, potentially database connection settings)
  • You can retrieve it correctly from the database
  • Whatever you want to display it on is able to support it (check the font, aside from anything else)

Given the number of ways in which it can go wrong, it's important to work out exactly where any problems are - which usually involves checking the UTF-16 code unit within the string you're trying to display, rather than just going straight for "does it display properly".

like image 70
Jon Skeet Avatar answered Mar 29 '23 11:03

Jon Skeet