Questions tagged [encode]

1

votes
1

answer
40

Views

Python string encode

I have this code att=att.replace("à","a") but I received this error... att=att.replace("à","a") UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: ordinal not in range(128) How can I fix?
Usi Usi
1

votes
1

answer
672

Views

How do I use encode_json with string in Perl?

Here is my code that I try to open the file to get data and change it to UTF-8, then read each line and store it in variable my $abstract_text and send it back in JSON structure. my $fh; if (!open($fh, '
Sleepz
1

votes
2

answer
1.7k

Views

PYTHON3 (and not is PYTHON2 ) TypeError: Won't implicitly convert Unicode to bytes; use .encode()

l have this function that works perfectly with python2 def writeCache(env, cache): with env.begin(write=True) as txn: for k, v in cache.items(): txn.put(k, v) However when l execute it with python3.5.2 it returns the following error : txn.put(k, v) TypeError: Won't implicitly convert Unicode to byt...
vincent75
1

votes
1

answer
5.9k

Views

javax.crypto.IllegalBlockSizeException: Input length not multiple of 16 bytes

I have an ArrayList which contains some objects. Object is a container for login/pass. I try to decode them because i have to serialize them into local file for recreation after another launch. Problem is during encryption I recieve javax.crypto.IllegalBlockSizeException: Input length not multiple...
rainbow
0

votes
0

answer
7

Views

TypeError: can't concat bytes to str in Python 3.5.1

I'm getting an error even after setting base64 encoding: Traceback (most recent call last): File "api_tufin_5.py", line 41, in main(sys.argv[1:]) File "api_tufin_5.py", line 28, in main headers['Authorization'] = 'Basic ' + base64.b64encode(user + ':' + password) TypeError: can't concat bytes to s...
pettyone
1

votes
2

answer
4.7k

Views

Problems using multipart_encode (poster library)

I am trying to upload a file using multipart_encode to realize the MIME process. However, I met the following error AttributeError: multipart_yielder instance has no attribute '__len__'. Below are is my approach, I really appreciate if anyone can give me some suggestions. url = "https://pi-user-file...
TH339
1

votes
1

answer
11

Views

Get only ASCII values from byte-encoded python string with hex characters

When I am trying to get data from a table in redshift and create a CSV file from it but while doing it I am facing a problem with bytes. b'INTERLEAVED\xff\x01\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00va...
gireeswar reddy
1

votes
3

answer
2.3k

Views

Determine if string is encoded HTML via jQuery?

I'm working on a validation script, but I'm running into a very particular issue. If a user enters a string that happens to be an encoded html character (like & or &), it will output as the character (& in this case). My question is this: is it possible to write a function that detemines if a string...
streetlight
1

votes
3

answer
1.4k

Views

PHP using urlencode results in Page Not Found error

I'm having a problem that's probably (hopefully) very easy to solve but I'm just about stuck. When I use the urlencode (or rawurlencode) function it will not find he script I'm sending it too. So this works fine: $data["text"] .= "".$row["region"].""; And it will take me to the correct page: index.p...
mr mojo risin
1

votes
2

answer
3.3k

Views

How to convert special characters, “Fran%c3%a7ais” -> “Français”? [duplicate]

Possible Duplicate: How to do URL decoding in Java? I have string "Fran%c3%a7ais". How can I convert it to correct "Français" ?
Tim
1

votes
2

answer
576

Views

does HTMLEncode(URLEncode(string)) always = URLEncode(HTMLEncode(string))?

I'm not sure if it's ever necessary to URL encode and HTML encode a string (well, perhaps unless you are building an html file that contains hyperlinks constructed using data pulled from a database or supplied by the user), but in any case, I wonder if the result is the same regardless of the order...
John Smith
1

votes
1

answer
440

Views

User data protection with encoding and decoding?

I'm working on a CMS system and I want to add a feature to protect user's data. Of course passwords are hashed and could only be decoded using brute forcing. But now it's about the rest of the data, for example their mail address. I would like to have a function which encodes a mail address when a u...
Tim Visée
1

votes
1

answer
12.9k

Views

How to use Server.htmlEncode / Server.htmlDecode without compromising security?

QUESTION How to submit html code to a textbox and output as text without compromising security? This is what I'm currently trying: DATA GOES IN (SUBMITTED INTO TEXTBOX) Dim txtInput As String = Server.HtmlEncode(Me.txtInput.Text) DATA COMES OUT (READ AS TEXT ON PAGE) txtOutput.Text = Server.HtmlDeco...
DreamTeK
1

votes
3

answer
5.1k

Views

Any simple encoding-decoding or crypt-decrypt class php for strings?

I've been looking in phpclasses, google, but couldn't find yet a simple encoding class that allows me to encode/crypt a string (unique number) into an unique short alphanumeric code and then decode/decrypt it back to original number. The main purpose is to encode facebook user ids in an app. Exampl...
Enrique
1

votes
2

answer
361

Views

Replacing words in Python?

I'm trying to replace the letters in key with the letters in alpha (and vice versa): alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" key = "XPMGTDHLYONZBWEARKJUFSCIQV" I am trying to change a string to become encoded (and the other way around), so say "Hello" would become "LTZZE". Any idea how to do this? Th...
1

votes
2

answer
606

Views

How can I convert HTML to plain text in CakePHP?

I’m making a little forum engine on CakePHP based more or less on phpBB. So, when somebody posts a message, they enter the text in a textarea, and on a beforeSave(), among other actions, the system uses Sanitize::html() to replace the characters to make HTML inputs safe. The problem is that when...
1

votes
1

answer
6.6k

Views

How to display both single and double quotes in textbox or textarea

In the database, the data string has both single and double quotes in them. Data string. A'B"C When it's displayed in a textbox or textarea, it's automatically encoded to html entities. Code in MVC view, vm is the object binded with knockout. vm.field1('@Model.field1'); Rendered HTML. A'B"C How...
Ray Cheng
1

votes
1

answer
375

Views

How to convert serialized byte array back to its text form

I have a text that is a property of an object.The object gets XmlSerialized and after that there is an element in the XML call Text that represents the text from the object.I am wondering how to turn it back to string. THE TYPE OF SERIALIZATION: XmlSerializer serizlizer = new XmlSerializer(typeof(Ac...
mathinvalidnik
1

votes
3

answer
2.7k

Views

Windows batch script containing binary executable

I want to create a windows batch script, which will have a base64 encoded program included. By included I mean - the encoded program will be "hardcoded" - there should be a "function" (or a code block) which will write the file line by line. (like in this question related to Linux Bash: Bash script...
Wojciech Danilo
1

votes
1

answer
668

Views

Encoding text to file / reading encoded text correctly to eradicate the  symbol?

Basically in my student data I am having an issue where by I am getting weird sumbols in my data as you can see: MAIN £1.00when it should show MAIN £1.00 Below is a snippet of my code what scrapes a website for certain student information for their student discounts and eventually writes it to...
Ryflex
1

votes
1

answer
1.3k

Views

Decode specific HTML tag from Encoded line

I got this Encoded HTML-line: <b><br /><i><br /><a><br /><br /><br /><br /><br /><br /><br><br /><br /><br /><br /><br /> This is saved in the database. When I read this from the database, I need to Decode this. But I only want to decode this tag: <br /> (the line contains multiple times this ta...
Swag
1

votes
1

answer
337

Views

JSON String Escaping - MathJax

I am trying to figure out how to have JS encode my MathJax string. Let's say I have: \(ax^2 + bx + c = 0\) This fails a JSON lint test, but is the valid code I would use to make the equation appear inline. Is there any built in method to do this in JS? componentURIEncode() Is not giving an appropria...
Diode Dan
1

votes
1

answer
1.2k

Views

use ffmpeg to parse info about presentation time in h264 stream encoded by MediaCodec

I have seen the below example for encode/decode using MediaCodec API. https://android.googlesource.com/platform/cts/+/jb-mr2-release/tests/tests/media/src/android/media/cts/EncodeDecodeTest.java In which there is a comparsion of the guessed presentation time and the presentation time received from d...
Phan Lac Phuc
1

votes
1

answer
2.7k

Views

Convert shift_jis to utf-8

I have a bunch of txt files that is encoded in shift_jis, I want to convert them to utf-8 encoding so the special characters can display properly. This has been probably asked before, but I can't seem to get it right. Update: I changed my code so it first write to a list then it will write the conte...
tonywang
1

votes
2

answer
124

Views

Can't remove first two encode characters using text editors in linux [duplicate]

This question already has an answer here: character showing up in files. How to remove them? 13 answers Using awk to remove the Byte-order mark 5 answers When I use text editor for seeing content of file a.csv it shows me: aaa bbb ccc ddd eee fff ggg hhh iii jjj kkk But when I cat it I have: �...
MLSC
1

votes
1

answer
761

Views

Python UTF-8 Latin-1 displays wrong character

I'm writing a very small script that can convert latin-1 characters into unicode (I'm a complete beginner in Python). I tried a method like this: def latin1_to_unicode(character): uni = character.decode('latin-1').encode("utf-8") retutn uni It works fine for characters that are not specific to the l...
Sifu
1

votes
4

answer
137

Views

Function that dynamically construct a byte array and return length

I need to create an encoder function in a class bool encodeMsg(unsigned char* buffer, unsigned short& len); This class has some fixed length members and some variable length vectors (of different structures). I have to encode a Byte stream based on some sequence of these member variables. Here is a...
creativeDrive
1

votes
2

answer
156

Views

MySQL to JSON Encode Error / No Results

I know this type of question has been asked a couple of times but my problem is a little bit different and I can't figure out of to fix this. I've checked other similar questions but couldn't find a solution since everything seems correct. I have a database table named KalkanliMekanlar and it has 3...
Poyraz Sagtekin
1

votes
2

answer
1.5k

Views

Replacing System.Web.Security.MachineKey.Encode with System.Web.Security.MachineKey.Protect

I just upgraded a project from .NET 4.0 to .NET 4.5.1 which produced the following warning: Public Shared Function Encode(data() As Byte, protectionOption As System.Web.Security.MachineKeyProtection) As String' is obsolete: 'This method is obsolete and is only provided for compatibility with existi...
Bob Bowles
1

votes
1

answer
62

Views

Strange encoding issue in PHP

I have been banging my head in the wall for couple of hours, I still couldn't figure out the issue. I have an associative array and when I try to build a query with it, It shows weird characters in the browser. $reportVars = [ "__report" => "alpha", "start_date" => "2001", "end_date" => "2002", "ds...
Fawzan
1

votes
1

answer
1.7k

Views

UnicodeEncodeError: 'charmap' codec can't encode characters in position 49-53: character maps to <undefined>

This is my code for creating a file character = open(namecharacter + '.txt', 'wt') character.write('Name: ' + namecharacter + '\n\nClass: ' + category + '\n\nHealth: ♥♥♥♥♥\n\nStrenght: ' + str(strength_new) + '\n\nDefense: ' + str(defense_new) + '\n\nDexterity: ' + str(dexterity_new) + '\n...
Jed Virchis
1

votes
2

answer
667

Views

jQuery replace “£” with “£” UTF-8

I'm trying to encode HTML special characters in strings from an uploaded file. It's working with everything except the "£" sign and, honestly, I have NO idea why I'm getting the text from an element using: var outputText = $("#displayAreaHidden").html(); outputText = encodeText(outputText); Then I'...
Mallander
1

votes
2

answer
2.9k

Views

How to Convert Pdf to base64 and Encode / Decode

OK, I have some pdf need convert to base64 by base64encoder. finally, I use decoder to convert back to pdf format but my content is lost. my code : byte[] input_file = Files.readAllBytes(Paths.get("C:\\user\\Desktop\\dir1\\dir2\\test3.pdf")); byte[] encodedBytes = Base64.getEncoder().encode(input_fi...
DKKs
15

votes
3

answer
10k

Views

How to convert all characters to their html entity equivalent using PHP

I want to convert this [email protected] to [email protected] I have tried: url_encode($string) this provides the same string I entered, returned with the @ symbol converted to %40 also tried: htmlentities($string) this provides the same string right back. I am using a UTF8 charset. not sure if this...
Ash
1

votes
2

answer
3.6k

Views

Send request to page with windows-1251 encoding from python

i need get a page source (html) and convert him to uft8, because i want find some text in this page( like, if 'my_same_text' in page_source: then...). This page contains russian text (сyrillic symbols), and this tag I use flask, and request python lib. i send request source = requests.get('url/') i...
user1478466
1

votes
4

answer
121

Views

Recovering filenames with bad encoding

I've been struggling with this problem for a while but working with encoding is so painful that I have to come to your smarter minds for some help. In a trip I made to Ukraine a friend copied to my pen drive me some Ukrainian named files. However, as you might expect, in the process of copying to my...
Felipe Ferri
11

votes
2

answer
51k

Views

Encode Python list to UTF-8

I have a python list that looks like that: list = [u'a', u'b', u'c'] Now I want to encode it in UTF-8. Therefore I though I should use: list = list[0].encode("utf-8") But print list gives only a meaning the first element of the list. Not even a list anymore. What am I doing wrong?
Tom
1

votes
2

answer
91

Views

u'囧'.encode('gb2312') throws UnicodeEncodeError

Firefox can display '囧' in gb2312 encoded HTML. But u'囧'.encode('gb2312') throws UnicodeEncodeError. 1.Is there a map, so firefox can lookup gb2312 encoded characters in that map, find 01 display matrix and display 囧. 2.Is there a map for tranlating unicode to gb2312 but u'囧' is not in that...
user3822769
2

votes
1

answer
502

Views

How to encoding the self link when there is a querystring in an RSS Feed

I am dynamically generating an RSS Feed for some of my pages. The issue is that the pages contain a query string in the URL to generate the content. When I place this URL into the tag is is no longer valid This sample code has the same issue and can be validated here RSS Feed http://localhost/?id=1...
John
2

votes
1

answer
2.1k

Views

Implement Manchester Encoding on Arduino

I am trying to program a manchester encoding for my arduino. This means a 1 bit is represented by 10 and zero is represented by 01. 1111 would be 10101010 in manachester code. My Program (C++ on Arduino) that encodes the char-array to manchester code looks like: //Output needs to be twice as big as...
Tobi

View additional questions