Skip to content

Commit

Permalink
Uploaded files
Browse files Browse the repository at this point in the history
  • Loading branch information
r-chow committed May 27, 2017
1 parent a404792 commit a080f71
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 1 deletion.
16 changes: 15 additions & 1 deletion README.md
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.
54 changes: 54 additions & 0 deletions discord.c
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();
}
Binary file added images/converted.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions slack.c
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();
}

0 comments on commit a080f71

Please sign in to comment.