Discord.js chinese characters appearing as boxes? - javascript

I have been working on a bot, it displays information, which includes names. Often these names are entirely/include Chinese characters. Whenever they do, they are converted into boxes or random characters. This sorta break the bot completely as it means you cant tell what box box symbol box means. I assume this is not only Chinese characters, I just haven't come across any others so far.
Looked it up on google, different phrases but found nothing even related to it on discord.js.
Any help would be greatly appreciated :D
Low quality and small ik..

Related

how to match continuous string input to passage in javascript, while showing mistakes?

Hey guys I am working on an application and so far its going well but while working on a recent features i am a little stuck.
Here is my problem:
using java script I am getting continuous user speech input and transcribing it. While I am getting this speech input i want to be able to identify and highlight the text on the screen that is being read. I want to highlight mistakes (words spoken that don't match) and I want to highlight all the content that is going correct.
I am not asking for someone to code this for me, i just want to be pointed in the right direction.
A similar implementation you have probably seen is in online typing games. where you try to type parts of a passage as fast as possible and it highlights the ones you are getting right and the ones that you are getting wrong.
Any help is appreciates, libraries, algorithms, methods, or terms I should search. Thank you !
Are you indexing the text at all? Do you know the text in advance? If you created an in memory graph database using each word in the text, you could search edges to find 'weighted' hits. It's ambitious, but there's an article here:
https://graphaware.com/neo4j/2016/07/07/mining-and-searching-text-with-graph-databases.html
If you want to go dirt simple and follow your typing game analogy:
In the typing game an event is fired each input (keypress).
The key pressed is compared to the expected one.
If it is not correct it is flagged as wrong.
There is usually no way to go back and correct the mistakes.
The user has to type the next expected letter correctly to
get things rolling correctly again.
You could do the same thing.
Underline the next expected word.
Each word (whitespace) is an event.
Match the text to speech word to the expected word.
If it is not right, flag it as wrong, strike it out.
The user has to say the next underlined word correctly to start things going smoothly again.
You could allow the user to back space the expected word so he/she could start over where they wanted to.
This will have some hiccups, as all things speech to text do, but it will work like your typing game and be simple to implement.

text string / word cloud ignore line break symbol

I have an implementation of the popular d3 word cloud. It has been working great for documents that are very lengthy, but I have been having an issue when I tried to re-purpose the word cloud to visualize a very simple txt file of the following format:
interesting. interesting. interesting.
boring. boring.
amazing. amazing. amazing.
stupid. stupid. stupid.
average. average.
disappointing.
(ect...)
It's basically just a txt file that has around 20 words. Each word repeats anywhere from 1 to 5 times. I would like this information to govern the sizing of the font (repeated 5 times = big font, 1 time = small font). When I put all the words on the same line, the resulting word cloud strangely makes all words the same font size. So I started to play around with it and tried a few different things. The closest I got to the desired effect was with the above txt format, having a line break after each new word.
This did result in the correct font sizing, but it also created a new problem. When I passed word_count object to the console log, I got something like this:
"⏎boring":1,
"boring":1,
"⏎stupid":1,
"stupid":2,
This means that the word cloud has repeated words in the visual (for example, the word "stupid" in large font size and also "stupid" in small font size). To make things more confusing, this behavior was isolated to a few words. Some words did not have the line break sign in front of them (even though I still hit enter in notepad when I made the txt in the same exact was as the ones that did wind up with the ⏎ sign.)
My next stab at fixing this was to add the "⏎" sign to the list of ignored words, hoping that would make the word cloud library treat them as if they were the same. Unfortunately for me, the problem persisted.
That sums it up pretty well; it's also really easy to reproduce, just need notepad and copy and paste my above words to see what I'm talking about.
Let me know if anyone has ideas for troubleshooting further.
Minimalist Block:
https://bl.ocks.org/diggetybo/cd644316f52465495f39c8fc27f04de8
(refreshing page will randomize the layout)

How to translate Japanese Kanji to Katakana

The requirement is to:
As the user type his/her Japanese Kanji first and last names,
automatically fill in the corresponding Japanese Katakana first and
last names.
I have been searching for a while now, but I couldn't yet find anything. There seems to be several jQuery plugins that convert Hiragama to Katakana or Romaji or vice-versa but that is not what we need here.
There is one that claims to translate from Kanji to Kana but I don't think the code matches his description (it only executes the code if the input is Kana but that is supposed to be the output!).
Anyway, I need to translate a person's first/last names from Kanji to Kana.
How do I do this?
As this needs to happen while the user is filling the form, I am prefer a JavaScript solution (or any pointers to it) but if there are any pointers how to do this in .NET, I'll very much appreciated too.
It seems like there are several JavaScript solutions online to convert from Kanji, Romaji, Hiragana and Katakana. Check these out and see if they work for you:
JQuery Auto Kana Input
Kuroshiro
jp-conversion
WanaKanaJS

Limit pasted words in multiple text area fields?

I'm a complete novice in JavaScript, so please forgive my ignorance. I've worked on this for several days, but it's beyond my skill level.
Please, could someone help me implement into this specific script: https://stackoverflow.com/a/11228092, something that limits words in each text area when pasted, too?
The script limits correctly when typing, but pasting sneaks past the word limit. To emphasize for clarity, I do mean counting words rather than characters.
I've tried looking at other methods, but they either limit characters rather than words, don't seem to apply to multiple, differing teaxtarea fields, or I just don't understand enough to implement them properly.
Thanks for any help anyone can give!

bidirectional text - visual to logical

I'm drawing texts on the screen letter by letter.
In English it is very simple, because the text is LTR so the letters are saved in the String in the same order they're shown.
When drawing RTL text than I need to switch the direction of the printing. but when there are letters and numbers and English and some RTL language.. than the mess starts.
For Ex.
ex.1: שלום לכם
ש- is the first letter in the string - but as we can see that it shown the last
ex.2: שלום to all
ש- is the first letter in the string- but as we can see that it is shown in the middle, before the English starts.
It is getting more complicated when numbers and math signs are getting into the picture, and special characters like '(', ')' that needed to be flipped...
Found many Bidi algorithm online that changes the logical order of the letters in the string to visual one. So when i run from left to right on the converted string i'm sure that the string will print properly.
BUT,
They are never perfect. There are cases that they are not working properly.
None of them considering the direction of the text as well (means when we press the right Ctrl+Shift on the keyboard than the visualization is changed again)
My questions are
does anybody know some bulletproof Bidi algorithm i can use to change the string from what it saved in the memory to visual order?
Is there a simpler way to solve my problem ? maybe somehow get the browser algorithm for it..
After searching for long time,
I've found that DOJO (and luckily it is the tool kit that i'm using),
has has a BIDI engine for drawing it's own UI controls, that gets few layout parameters to handle some cases of RTL, LRT, and contextual directions as well.
If this is helping someone -
http://bill.dojotoolkit.org/api/1.9/dojox/string/BidiEngine
Found another link that might help to a none DOJO developers -https://github.com/ibm-js/dbidi, but I have not check it yet

Categories

Resources