Comments (4)
Hi Lawrence - wow - that is fantastic - thank you very much for all of your help - much appreciated :-)
Jim
from emoji-parse.
Hi @u20200522,
It needed a check to see if it had a description, I've added it in: https://github.com/lcherone/emoji-parse/blob/master/parse.13.0.php
'description' => isset($icon[1]) ? trim($icon[1]) : '',
from emoji-parse.
Hi Lawrence,
Thanks for your reply and the new version. Sorry to ask for coding advice...
I was trying to assign variables to each of the emoji elements so I can insert them into a MySQL table.
When I run my code against the Version 13 TXT file, the Smileys & Emotion
group value is empty, but for all the other lines, the group value is picked up. However, for the Version 5 TXT file, this is not an issue at all.
When I run my code, it errors with:
Notice: Undefined variable: group in C:\Apache24\htdocs\02-external-to-mysql\unicode-live2.php on line 74
This is line 74:
$var_group = trim($group);
I think this is happening because there is an issue with the text before the first group
value being declared.
This is the text from Version 5, leading up to the first group declaration:
# Notes:
# • This currently omits the 12 keycap bases, the 5 modifier characters, and 26 singleton Regional Indicator characters
# • The file is in CLDR order, not codepoint order. This is recommended (but not required!) for keyboard palettes.
# • The groups and subgroups are purely illustrative. See the Emoji Order chart for more information.
# group: Smileys & People
# subgroup: face-positive
For Version 13, there are 2 empty lines before the first group declaration:
# Notes:
# • This includes the emoji components that need emoji presentation (skin tone and hair)
# when isolated, but omits the components that need not have an emoji
# presentation when isolated.
# • The RGI set is covered by the listed fully-qualified emoji.
# • The listed minimally-qualified and unqualified cover all cases where an
# element of the RGI set is missing one or more emoji presentation selectors.
# • The file is in CLDR order, not codepoint order. This is recommended (but not required!) for keyboard palettes.
# • The groups and subgroups are illustrative. See the Emoji Order chart for more information.
# group: Smileys & Emotion
I presume that's it, as throughout the rest of the version 5 and version 13 files, there is always 1 empty line before the group declarations, except on version 13, there are two empty lines before the first group declaration.
Is there any way to accommodate that difference?
Thanks again
Jim
PS - my code is here (the rest of my code is the same as yours):
foreach ($lines as $line) {
$subgroup = trim(str_replace('# subgroup:', '', $top));
$linegroup = explode(';', $line);
$parts = explode('#', $linegroup[1]);
$icon = explode(' ', trim($parts[1]), 2);
$var_codepoint = trim($linegroup[0]);
$var_status = trim($parts[0]);
$var_group = trim($group);
$var_sub_group = trim($subgroup);
$var_emoji = trim($icon[0]);
$var_emojiname = trim($icon[1]);
echo "<p>Codepoint: <b>$var_codepoint</b></p>";
echo "<p>Insert Codepoint: <b style='color:green;'>$var_codepoint</b></p>";
$sql2 = "INSERT INTO xx_emoji_data_unicode
(codepoint
, unicode
, status
, category
, subcategory
, emoji
, emojiname
, version_number)
VALUES (:var_codepoint1
, :var_codepoint2
, :var_status
, :var_group
, :var_sub_group
, :var_emoji
, :var_emojiname
, :version_number)";
$stmt2 = $pdo->prepare($sql2);
$stmt2->bindParam(':var_codepoint1', $var_codepoint);
$stmt2->bindParam(':var_codepoint2', $var_codepoint);
$stmt2->bindParam(':var_status', $var_status);
$stmt2->bindParam(':var_group', $var_group);
$stmt2->bindParam(':var_sub_group', $var_sub_group);
$stmt2->bindParam(':var_emoji', $var_emoji);
$stmt2->bindParam(':var_emojiname', $var_emojiname);
$stmt2->bindParam(':version_number', $version_number);
$stmt2->execute();
}
from emoji-parse.
No probs, I think it was this line: $top = explode(PHP_EOL, $chunk)[0];
it needed a trim $top = explode(PHP_EOL, trim($chunk))[0];
.
Also, they seem to have added some kind of version code to the beginning of the description, so I made a fix for that which is version
.
See parse.php
for updated change.
See index.php
for how I tested importing into mysql, hope it helps.
from emoji-parse.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from emoji-parse.