-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
123 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,15 @@ | ||
discord-text-to-emoji | ||
# Discord Text to Emoji # | ||
|
||
This program converts a string to emojis in Discord, and automatically copies the result to clipboard. It accepts alphanumeric strings. If a non-alphanumeric character is inputted, it will simply spit out **:regional\_indicator\_<char>:** For example: | ||
|
||
**abc 123** | ||
|
||
will become | ||
|
||
**:regional\_indicator\_a: :regional\_indicator\_b: :regional\_indicator\_c: :one: :two: :three:** | ||
|
||
which displays as | ||
|
||
![Converted text](/images/converted.png) | ||
|
||
The binaries are compiled using Mingw-w64 for 64-bit Windows. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include <stdio.h> | ||
#include <ctype.h> | ||
#include <stdlib.h> | ||
#include <mem.h> | ||
#include <rpc.h> | ||
//#include <rpc.h> | ||
|
||
int main() { | ||
char output[1000] = ""; | ||
char prefix[21] = ":regional_indicator_"; | ||
char *numbers[] = {":zero:\0", ":one:\0", ":two:\0", ":three:\0", ":four:\0", ":five:\0", ":six:\0", ":seven:\0", ":eight:\0", ":nine:\0"}; | ||
|
||
char input[1000]; | ||
printf("Please input the string to be converted: "); | ||
fgets(input, 1000, stdin); | ||
|
||
long length = (long) strlen(input); | ||
for (int i = 0; i < length - 1; i++) { | ||
if (isdigit((input[i]))) { | ||
char *current; | ||
current = malloc(sizeof(int) * 2); | ||
current[0] = input[i]; | ||
current[1] = '\0'; | ||
|
||
int digit; | ||
digit = atoi(current); | ||
|
||
char src[12]; | ||
strcpy(src, numbers[digit]); | ||
strcat(output, src); | ||
strcat(output, " "); | ||
} | ||
else { | ||
if (input[i] == ' ') { | ||
strcat(output, " "); | ||
} | ||
else { | ||
char current[2]; | ||
current[0] = (char) tolower(input[i]); | ||
strcat(output, prefix); | ||
strcat(output, current); | ||
strcat(output, ": "); | ||
} | ||
} | ||
} | ||
|
||
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, 1001); | ||
memcpy(GlobalLock(hMem), output, 1001); | ||
GlobalUnlock(hMem); | ||
OpenClipboard(0); | ||
EmptyClipboard(); | ||
SetClipboardData(CF_TEXT, hMem); | ||
CloseClipboard(); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include <stdio.h> | ||
#include <ctype.h> | ||
#include <stdlib.h> | ||
#include <mem.h> | ||
#include <rpc.h> | ||
//#include <rpc.h> | ||
|
||
int main() { | ||
char output[1000] = ""; | ||
char prefix[9] = ":letter_"; | ||
char *numbers[] = {":zero:\0", ":one:\0", ":two:\0", ":three:\0", ":four:\0", ":five:\0", ":six:\0", ":seven:\0", ":eight:\0", ":nine:\0"}; | ||
|
||
char input[1000]; | ||
printf("Please input the string to be converted: "); | ||
fgets(input, 1000, stdin); | ||
|
||
long length = (long) strlen(input); | ||
for (int i = 0; i < length - 1; i++) { | ||
if (isdigit((input[i]))) { | ||
char *current; | ||
current = malloc(sizeof(int) * 2); | ||
current[0] = input[i]; | ||
current[1] = '\0'; | ||
|
||
int digit; | ||
digit = atoi(current); | ||
|
||
char src[12]; | ||
strcpy(src, numbers[digit]); | ||
strcat(output, src); | ||
strcat(output, " "); | ||
} | ||
else { | ||
if (input[i] == ' ') { | ||
strcat(output, " "); | ||
} | ||
else { | ||
char current[2]; | ||
current[0] = (char) tolower(input[i]); | ||
strcat(output, prefix); | ||
strcat(output, current); | ||
strcat(output, ": "); | ||
} | ||
} | ||
} | ||
|
||
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, 1001); | ||
memcpy(GlobalLock(hMem), output, 1001); | ||
GlobalUnlock(hMem); | ||
OpenClipboard(0); | ||
EmptyClipboard(); | ||
SetClipboardData(CF_TEXT, hMem); | ||
CloseClipboard(); | ||
} |