encoding

Why does the PHP json_encode function convert UTF-8 strings to hexadecimal entities?

偶尔善良 提交于 2020-01-18 04:35:31
问题 I have a PHP script that deals with a wide variety of languages. Unfortunately, whenever I try to use json_encode , any Unicode output is converted to hexadecimal entities. Is this the expected behavior? Is there any way to convert the output to UTF-8 characters? Here's an example of what I'm seeing: INPUT echo $text; OUTPUT База данни грешка. INPUT json_encode($text); OUTPUT "\u0411\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u0438 \u0433\u0440\u0435\u0448\u043a\u0430." 回答1: Since PHP/5.4.0,

Short rot13 function - Python [closed]

笑着哭i 提交于 2020-01-18 03:57:26
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . I am searching for a short and cool rot13 function in Python ;-) I've written this function: def rot13(s): chars = "abcdefghijklmnopqrstuvwxyz" trans = chars[13:]+chars[:13] rot_char = lambda c: trans[chars.find(c)] if chars.find(c)>-1 else c return ''.join( rot_char(c) for c in s

How to change utf-8mb4 to UTF-8 in groovy?

ε祈祈猫儿з 提交于 2020-01-17 12:26:04
问题 Currently, I have a problem with receiving string input from user mobile. The string was inputed and contained utf8mb4 characters (smiley, emoji, etc). This caused error in my backend (mysql) since it only accepts utf-8 input. Now, how can I just replace all utf-8mb4 input to utf-8? def utf8mb4string = '👳👳👳👳👳👳👳'; // parse the utf8mb4string to utf8 // logic here //possible utf8 result maybe: '�������' I have also found similar question here How would I convert UTF-8mb4 to UTF-8? but no clear

Sending email containing accent with powershell

…衆ロ難τιáo~ 提交于 2020-01-17 07:22:48
问题 I'm trying to send emails containing accents via powershell. If i do the following : $enc = [System.Text.Encoding]::UTF8 Send-MailMessage -to "Recipient@company.com" -from "Sender@company.com" -subject "test" -body "éèà" -Encoding $enc It actually works and i get the accents fine in the mail. BUT, if i do this : $enc = [System.Text.Encoding]::UTF8 $Body = @" éèà "@ Send-MailMessage -to "Recipient@company.com" -from "Sender@company.com" -subject "test" -body $body -Encoding $enc The email

Sending email containing accent with powershell

我怕爱的太早我们不能终老 提交于 2020-01-17 07:22:25
问题 I'm trying to send emails containing accents via powershell. If i do the following : $enc = [System.Text.Encoding]::UTF8 Send-MailMessage -to "Recipient@company.com" -from "Sender@company.com" -subject "test" -body "éèà" -Encoding $enc It actually works and i get the accents fine in the mail. BUT, if i do this : $enc = [System.Text.Encoding]::UTF8 $Body = @" éèà "@ Send-MailMessage -to "Recipient@company.com" -from "Sender@company.com" -subject "test" -body $body -Encoding $enc The email

nodejs pbkdf2sync Not a buffer error

最后都变了- 提交于 2020-01-17 05:16:09
问题 Suddenly in my console it's start giving errors, and it has been running fine for days without any change. Please advise. /node_modules/mysql/lib/protocol/Parser.js:82 throw err; ^ TypeError: Not a buffer at TypeError (native) at pbkdf2 (crypto.js:607:20) at Object.exports.pbkdf2Sync (crypto.js:590:10) crypto: require("crypto"), encrypt: function(password) { var salt = this.getSalt(password, this.constructor.GUID); return {salt: salt, password: this.getEncrypted(password, salt)}; }, getSalt:

MySQL encoding issue with Turkish characters

笑着哭i 提交于 2020-01-17 04:03:49
问题 I'm using WAMP server. I have my php.ini set to utf-8 and also I have header('Content-Type: text/xml; charset=utf-8'); in my php and @mysql_query("SET NAMES utf8"); in my connection file. MySQL collation is set to utf8_turkish_ci and when I write my queries directly from phpMyAdmin the Turkish characters ç,ş,ö,ğ etc. show properly. But when I try to submit them from a php form, they turn into strange characters on the database, however when I write them again with php, they show properly. My

How to encode a URL for passing it as a GET parameter

你。 提交于 2020-01-17 03:35:06
问题 I load a JavaScript file which takes current page's URL as a parameter. Here is the code I use: document.write(unescape('%3Cscript src=\"' + _vis_opt_protocol + 'domain.com/js.php&a='+account_id+'&url='+encodeURIComponent(document.URL)+'&random='+Math.random()+'\" type=\"text/javascript\"%3E%3C/script%3E')); I thought encodeURIComponent will do the job of properly encoding the URL. However, while loading JS file, browsers interpret the encoded URL too. For example if the document.URL is http:

How to encode a URL for passing it as a GET parameter

冷暖自知 提交于 2020-01-17 03:34:08
问题 I load a JavaScript file which takes current page's URL as a parameter. Here is the code I use: document.write(unescape('%3Cscript src=\"' + _vis_opt_protocol + 'domain.com/js.php&a='+account_id+'&url='+encodeURIComponent(document.URL)+'&random='+Math.random()+'\" type=\"text/javascript\"%3E%3C/script%3E')); I thought encodeURIComponent will do the job of properly encoding the URL. However, while loading JS file, browsers interpret the encoded URL too. For example if the document.URL is http:

PowerShell EncodedCommand Failing

Deadly 提交于 2020-01-17 01:29:05
问题 I'm trying to pop up a simple message box using Powershell's -EncodedCommand flag, but it keeps failing. I've tried Googling for the last few hours, but can't seem to get this working. It almost looks like an encoding error, but I'm using regular UTF-8 with standard ASCII backwards-compatible characters. The command that keeps failing: Powershell.exe -EncodedCommand