encoding

Arabic presentation forms B support in c#

こ雲淡風輕ζ 提交于 2020-01-13 02:50:09
问题 I was trying to convert a file from utf-8 to Arabic-1265 encoding using the Encoding APIs in C#, but I faced a strange problem that some characters are not converted correctly such as "لا" in the following statement "ﻣﺣﻣد ﺻﻼ ح عادل" it appears as "ﻣﺣﻣد ﺻ? ح عادل". Some of my friends told me that this is because these characters are from the Arabic Presentation Forms B. I create the file using notepad++ and save it as utf-8. here is the code I use StreamReader sr = new StreamReader(@"C:\utf-8

C# SHA256 ComputeHash result different with CryptoJS SHA256 function

浪尽此生 提交于 2020-01-12 22:22:53
问题 I have a C# function as below: string stringvalue = "530500480530490480530480480520570480520510500490"; var encodedvalue= Encoding.Unicode.GetBytes(stringvalue); using (HashAlgorithm ssp = System.Security.Cryptography.HashAlgorithm.Create("SHA256")) { var digest = ssp.ComputeHash(encodedvalue); return BitConverter.ToString(digest); } I need to create a javascript function that match the code above so that the end result for both C# and JS is the same. Currently in my JS code, I'm using this:

Why are RISC-V S-B and U-J instruction types encoded in this way?

核能气质少年 提交于 2020-01-12 18:57:32
问题 I am reading a book "Computer Organization and Design RISC-V Edition" , and I came across the encoding for S-B and U-J instruction types. Those types I have mentioned above has strange encoded immediate field. S-B types separate the immediate field into 2 parts. This makes sense since all instructions encoding has to be similar. But I cannot understand why the immediate field is encoded in this way below. imm[12, 10:5], imm[4:1, 11] instead of imm[11:5], imm[4:0] U-J types also have this

Why are RISC-V S-B and U-J instruction types encoded in this way?

落花浮王杯 提交于 2020-01-12 18:57:00
问题 I am reading a book "Computer Organization and Design RISC-V Edition" , and I came across the encoding for S-B and U-J instruction types. Those types I have mentioned above has strange encoded immediate field. S-B types separate the immediate field into 2 parts. This makes sense since all instructions encoding has to be similar. But I cannot understand why the immediate field is encoded in this way below. imm[12, 10:5], imm[4:1, 11] instead of imm[11:5], imm[4:0] U-J types also have this

Python HTML Encoding \xc2\xa0

女生的网名这么多〃 提交于 2020-01-12 13:56:00
问题 I've been struggling with this one for a while. I'm trying to write strings to HTML but have issues with the format once I've cleaned them. Here's an example: paragraphs = ['Grocery giant and household name Woolworths is battered and bruised. ', 'But behind the problems are still the makings of a formidable company'] x = str(" ") for item in paragraphs: x = x + str(item) x Output: "Grocery giant and household name\xc2\xa0Woolworths is battered and\xc2\xa0bruised. But behind the problems are

PHP string to hex

牧云@^-^@ 提交于 2020-01-12 08:00:15
问题 I have a string like that: [0-9A-Za-z\+/=]* How can I converted in the following form: "\133\x30\55\x39\101\x2d\132\x61\55\x7a\134\x2b\57\x3d\135\x2a" Is there any function for that ? 回答1: function strtohex($string) { $string = str_split($string); foreach($string as &$char) $char = "\x".dechex(ord($char)); return implode('',$string); } print strtohex("[0-9A-Za-z\+/=]*"); The above code will give you \x5b\x30\x2d\x39\x41\x2d\x5a\x61\x2d\x7a\x5c\x2b\x2f\x3d\x5d\x2a I'm aware that it doesn't

How to download a file through a custom POST request with CasperJS

无人久伴 提交于 2020-01-11 11:42:36
问题 I am writing a crawler and needs to download file generated after a form request using POST. I have successfully used this.download(url,'POST',Params) for regular forms. One of the sites has many fields using the same name, thus preventing me from using the regular download method. After trying a lot of things, I tried with $.ajax() and __utils.sendAJAX() to process the form like this: response = this.evaluate(function(){ url=... params = $('form#theirForm').serialize(); data = __utils__

c# encoding problems (question marks) while reading file from StreamReader

此生再无相见时 提交于 2020-01-11 10:18:29
问题 I've a problem while reading a .txt file from my Windows Phone app. I've made a simple app, that reads a stream from a .txt file and prints it. Unfortunately I'm from Italy and we've many letters with accents. And here's the problem, in fact all accented letters are printed as a question mark. Here's the sample code: var resourceStream = Application.GetResourceStream(new Uri("frasi.txt",UriKind.RelativeOrAbsolute)); if (resourceStream != null) { { //System.Text.Encoding.Default, true using

How to pipe the output of a command to a file without powershell changing the encoding?

谁说我不能喝 提交于 2020-01-11 10:11:41
问题 I want to pipe the output of a command to a file: PS C:\Temp> create-png > binary.png I noticed that Powershell changes the encoding and that I can manually give an encoding: PS C:\Temp> create-png | Out-File "binary.png" -Encoding OEM However there is no RAW encoding option, even the OEM option changes newline bytes ( 0xA resp 0xD ) to the windows newline byte sequence ( 0xD 0xA ) thereby ruining any binary format. How can I prevent Powershell from changing the encoding when piping to a file

How to pipe the output of a command to a file without powershell changing the encoding?

天涯浪子 提交于 2020-01-11 10:09:06
问题 I want to pipe the output of a command to a file: PS C:\Temp> create-png > binary.png I noticed that Powershell changes the encoding and that I can manually give an encoding: PS C:\Temp> create-png | Out-File "binary.png" -Encoding OEM However there is no RAW encoding option, even the OEM option changes newline bytes ( 0xA resp 0xD ) to the windows newline byte sequence ( 0xD 0xA ) thereby ruining any binary format. How can I prevent Powershell from changing the encoding when piping to a file