How do i Prevent CKEditor convert hexadecimal character to decimal character? - javascript

I'm working in CKEditor a few weeks ago.I face some issues now.
CKEditor automatically converts the hexadecimal character to decimal character.
This is the Hexa char I gave t
o the editor.
–
What CKEditor converts.
&
How do I prevent this conversion.
Please, anybody help me to solve this issue.

You may use config.entities_additional like:
config.entities_additional = '#x2013';
to tell CKEditor that this entity could be used inside the editor (so it won't get converted).

Related

japanese keyboard format number commas duplicate

keyboard format number commas duplicate
I have a problem when use JS formatting input number comma with the Japanese keyboard on IOSjapanese
I used: numStr.replace(/\B(?=(\d{3})+(?!\d))/g, ',') to format a number with commas as thousands of separators.
everything worked fine except when I tested with the Japanese keyboard on the IOS environment returned duplicate.
I found the problem because I use String. prototype.replace(). It returns right value. but when I use this vue with numStr.replace(/\B(?=(\d{3})+(?!\d))/g, ','). It returns incorrectly.
I have no idea what is the problem...
Thank you for being so helpful.

Using German characters (e.g. Umlaut) in HTML

I am trying to encode German characters in html. I just want to use the special character codes. For the Umlaut, I've tried using both Ü and Ü and neither renders properly. What am I doing wrong? Thanks.
This is for a Squarespace site, and I am inserting Javascript into their Code Injection page, into the footer. I am using Javascript to write a German word on the page. The relevant part of my code looks like the below. And the problem is that this simply renders "& U uml;ber' (space added by me because the umlaut renders properly on Stack Overflow without it) on the page rather than Uber with an umlaut. Thanks!
var strings = {
'About': {
'de': 'Über'
},
Try using Ü for the German character Ü.
You need to escape special characters in HTML, unless...
You address the encoding issue on a document-wide level by adding the following line of code at the beginning of the <head> section:
<meta charset="utf-8">
Then you don't need to escape special characters individually.
Further reading:
Character encodings for beginners
Declaring character encodings in HTML
Declaring character encodings in CSS
UPDATE 1 (Javascript)
Convert special characters to HTML in Javascript
How to convert characters to HTML entities using plain JavaScript
UPDATE 2 (Squarespace)
HTML Special Characters and Squarespace
special character in squarespace (text block)
If you are a Squarespace customer, they provide 24/7 customer support. Contact them directly.
This solution worked for me. Use the hex code but eliminate the &# from the beginning and add a /
So, to render the word "Über" within Javascript in Squarespace, use /xdcber

using unicode symbols in ngOption <select>

Hello I've ran into an issue that is stumping me:
So I have an ngOption that loops through and displays unicode symbols
<select class="form-control symbolSelect" ng-model="input.loadSymbol" ng-options="d as d.TagShpUTF for d in loadSymbols" ng-change=""></select>
Here is an example jsFiddle showing it working: http://jsfiddle.net/tjm9a6o2/
I set up the datasource to have a unicode character like so: loadsymbols[0].TagShpUTF = '\u2660'
This all works fine as static data, but when I try to pull the data from my DB it displays it as regular text and doesn't seem to know it's special unicode characters.
This is how I have it setup in the DB (Don't mind other columns, TagShpUTF is the important one):
...what I think it's doing is automatically add a second slash '\' so it can be a valid string, but I don't want that to happen. I want it to be recognized as unicode so it shows the symbols in my dropdown (like jsFiddle), but instead it's showing the actual text (like '\u2660').
Any suggestions would be very helpful. Really need a way of storing these symbols and loading them into a drop down. I tried HTML unicode symbols, but they were giving me even more problems than this method. Thanks!
Eureka!!!
So after many painful attempts and exhausting the kind help from #OrGuz, I kind of gave up on using the \u version of unicode and started looking at HTML-Code version again.
I stumbled upon this SO post buried in the garbage i've been digging through. It had a link to a MDN page about String.fromCharCode()
By storing the HTML- Code number in my DB and calling String.fromCharCode()
I was able to load the symbol in the drop down.
spade: HTML-Code= ♣
TagShpUTF= 9827
String.fromCharCode(TagShpUTF); <---- Works!

I want to strip certain characters from a textarea - PHP/Javascript [duplicate]

This question already has answers here:
How to replace Microsoft-encoded quotes in PHP
(6 answers)
Closed 9 years ago.
The Details
I have a simple textarea <textarea></textarea>
The value of this textarea is sent through ajax and stored in a database.
The value in this database is viewed on an iPad (or iPad mini or iPhone, etc)
The Problem
When someone copies text from somewhere (could be anywhere from the internet potentially), I want to remove any weird characters such as: “windows-1252 quotes” from the text before storing them in a utf8_unicode_ci column in a database. This column stores the above quotes but are unknown on certain devices (like iPad)
The Question
How can I remove these characters in Javascript or PHP?
string.replace has been tried from various examples to remove these characters.
htmlentities($sample) has been tried in order to convert these characters but still no luck.
Any help would be appreciated! Thanks!
Regular expressions will do this; php's function for this is preg_replace, javascript's is simply .replace(). You can find usage snippets everywhere ;)
There are two ways to approach this using regex:
1. Define an allowed character range and strip anything that isn't in that range.
[^\w-=+()!##$%^*(] will match NOT anything in this character range (the ^ at the beginning of the character class denotes this). You can then take the resulting matched characters and replace with an empty string.
Working example: http://regex101.com/r/zK2qW6
2. Define a non-allowed character range and strip anything that is in that range.
[“”] will match anything in this character range. You can then take the resulting matched characters, and again replace with an empty string. You could also use a regex unicode range here too.
Working example: http://regex101.com/r/yG4qJ4
In the end, you should choose the path which requires the smallest expression. If there's only a handful of characters to replace, use option #2. If you only want to allow a handful of characters, use option #1.

Javascript replace() function adding strange characters

Consider the following Javascript:
var previewImg = 'http://example.com/preview_img/hey.jpg';
var fullImg = previewImg.replace('preview','full');
I would expect the value of fullImg to be:
http://example.com/full_img/hey.jpg
In fact, it is... sort of. Running alert(fullImg); shows the expected url string. But when I deliver that variable to jQuery Fancybox, like this:
jQuery.fancybox.open(fullImg);
Something adds characters into the string, like this:
http://example.com/%EF%BF%BCfull_img/hey.jpg
Where is this %EF%BF%BC coming from? What is it? And most importantly, how do I get rid of it?
Some other clues: This is a Drupal 7 site, running jQuery 1.5.1. I'm using that same Fancybox script elsewhere on the site with no issues.
%EF%BF%BC is a sequence of three URL-encoded characters.
You clearly can't see any unexpected characters in the string. That's because the character sequence %EF%BF%BC is invisible.
It's actually a UTF-8 byte-order mark sequence. This sequence typically comes at the start of a UTF-8 encoded text file. They probably got into your code when you did a copy+paste from another file.
The quickest way to get rid of them is to find the bit of code that was copied+pasted, delete the characters on either side of the problem, and retype them. Depending on your editor, you may find the delete behaves strangely as it deletes the hidden characters.
Some text editors and IDEs will have an option to show hidden characters. If your editor has this, it may help you see where the mystery characters are so you can delete them.
Hope that helps.

Categories