Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write the following functions: Part 2 : An Emoji Translator For the second part of this MP you will create a emoji translation utility. Unlike

Write the following functions:
Part 2: An Emoji Translator
For the second part of this MP you will create a emoji translation utility. Unlike emoji_invertChar, these translations might change the length of the string, meaning youll need to impement some kind of data structures to support the translation.
In emoji-translate.c, you will find four functions:
void emoji_init(emoji_t *emoji) is called to initialize an emoji object.
void emoji_add_translation(emoji_t *emoji, const unsigned char *source, const unsigned char *translation) adds a translation to the emoji object. For example, might translate to diamond.
const unsigned char *emoji_translate_file_alloc(emoji_t *emoji, const char *fileName) must translate the contents of the file specified by fileName using all translation rules added so far. When matching rules, always choose the longest matching rule based on the length of the source.
For example, if only one rule => diamond has been added: "s are forever!" would translate to "diamonds are forever!".
If the rule => diamond and => Bejeweled, " with s" would translate to "Bejeweled with diamonds", not "diamonddiamonddiamond with diamnds" since the rule using three emoji is the longer than the one with one emoji.
void emoji_destroy(emoji_t *emoji) is called to destroy the emoji object and any memory allocated by your emoji library.
Example Usage
emoji_t emoji;
emoji_init(&emoji);
emoji_add_translation(&emoji, "", "heart");
// The file on disk contains: "I Illinois!"
unsigned char *translation = emoji_translate_file_alloc(&emoji, "tests/txt/simple.txt");
// Translation Output: "I heart Illinois!"
printf("%s
");
emoji_destroy(&emoji);

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Nested Relations And Complex Objects In Databases Lncs 361

Authors: Serge Abiteboul ,Patrick C. Fischer ,Hans-Jorg Schek

1st Edition

3540511717, 978-3540511717

More Books

Students also viewed these Databases questions