What are these question marks in my Android logfile? - java

Can someone please tell me what this means:
07-04 09:54:38.048: I/DetailActivity(15496): Title that is set : ��Le
I got this from a log file for an android app that I am writing. This is in a String variable and the data comes from a Parcable method that I used to pass data from one activity to another. Please let me know if you need the code, but I'm hoping someone can explain what they are rather than w

Looks like a character encoding issue. The two characters are represented by a series of bits in your app (probably UTF-8) that do not translate to ASCII.
Read Joel on Software's blog post on the subject.

Related

Can anyone tell me the type of character encoding used within these Strings? [Decompiled]

Currently working on a project for a client that involves re modelling a decompiled and obfuscated set of code from a jar that's rather large.
There's a set of strings that keep popping up to be decoded consistently however the methods to decode said strings have been scrambled to the point of illegibility, from previously asking on here no one has time to be crawling through the method to figure out an alternate solution, so instead figuring out the character encoding is the best way to create a solution for the issue.
*Note that the obfuscator used does not have the ability to encrypt hard coded strings
I've tried varying methods of conversion from different libraries and different character sets however it doesn't seem to be playing ball, I asked a much more complex question here earlier but instead the more effective solution is to begin from knowing how to decode it from the start, below are some examples of the strings.
String encodedPriceExample = "\0163J\032'\032J\037\"m\007:P$\031";
//from interpretation shows a price of a transaction
String encodedErrorMessageExample ="V5T\016\005\"J:\037$\036w\0062\013!\017w\0238\037%J4\037%\0302\004#J1\0134\036>\0059J5\0171\005%\017w\0238\037wO$D";
//longer one, should show a no join message of some form.
These are only two strings, however all of them look similar and are decrypted via a scrambled static method as previously said.
Does this character encoding look like any character encoding at all? needs to be converted into UTF-8 or Base64.
Due to it going through a decompiler the string itself may just be jumbled and converted into raw unicode of some form, however I've never seen it happen before even with obfuscation, other hard coded strings in the project are fine, just the strings in those static methods.
Any input and / or help would be greatly appreciated in sorting this out! This is more of a check to make sure that my angle for fixing it up is correct.
Thanks guys

How can I edit a text file using Java without storing all the content in a string?

I was looking back at some older class assignments and for one the user had to provide a text file which would be encoded according to an encryption key the user also gave. I essentially solved the problem by placing the content of the text file within a string, retrieving each letter from the string and encrypting it, and then printing the encrypted character back into the same text file. The problem is my professor docked 5% for storing the whole file content within a string, writing something like: "What if the file contents were very large?" I even recall the few people I talked to after the project was graded saying they lost points for the same reason.
At the time I thought he made sense and was too overburdened by my workload so didn't bother seeing if I could fix it because it seemed to be reasonable and simple enough. However now I can't understand how one would be able to edit the text file directly or write on the same file without storing the entire string (because one would otherwise lose its content). How would someone even go about this? Thank you!
Edit: whomever marked my thread as a duplicate to the one above clearly did not understand my question. I am asking how to manipulate the same file without using an absurd amount of memory as the solution I stated would. The other thread clearly asks what the quickest way to read from a file is, which is not at all the same thing. Joop had the right idea of what I meant so I'll try just that, thank you Joop.

showDocument() with non-standard (Chinese) characters

So, I finally discovered that JavaFX lets you use HostServices.showDocument(uri) to open a browser to the given url. I have run into a problem though; I cannot open up urls that contain Chinese characters. It can only interpret them as '?', taking you to the wrong url. AWT's Display.browse(uri) handles characters without a problem, so I know that it can be communicated to the browser technically. I'm not sure if there is anything I can do on my end or not though.
My question is: Is there any way to make JavaFX's HostServices.showDocument() correctly read in Chinese characters?
EDIT:
Sample string
http://www.mdbg.net/chindict/chindict.php?page=worddict&wdrst=0&wdqb=%E6%96%87
You can follow the link through to see the address' chinese character (at the very end of the url). So in doing this, I noticed that it converts the character to a series of %, letters, and numbers. Plugging those into showDocument() in place of the character works fine. So then, I guess the question is now "How do I convert a character to this format?
I was able to figure out that converting the string into a URI, then using the .toASCIIString() method gave me what I needed. (Converting Chinese characters, and I would assume others, into something readable by showDocument(). Thanks for the help jewelsea.
If there is a better way to do this, feel free to give me another answer.

MediaMetadataRetriever extractMetadata string encoding

When I use the extractMetadata( MediaMetadataRetriever.METADATA_KEY_TITLE ) function.
Some of the strings returned are displayed incorrectly.
i.e.
Christina Perri - A Thousand Years
is displayed as
䌀栀爀椀猀琀椀渀愀 倀攀爀爀椀 ⴀ 䄀 吀栀漀甀猀愀渀搀 夀攀愀爀猀
Does anyone have any tips as to how I can get the string to display correctly?
I have no idea about Android, but there are two possibilities
You are reading it correctly and someone used this characters while storing the data.
You get the wrong characters because the text you get, has been stored in a different enconding, than you are using to display it. In this case you need to tell Java in which encoding this string is.
A good start to read about encodings is this blog
The Java tutorial for working with text

Arabic Encoding in UFT-8 from Web Service

I am trying to encode Arabic text from a Web service. Currently the values come as question marks (???).
I have read many blogs (even stackoverflow answers/links) but nothing seems to worked.
Any idea of how I can resolve this issue?
Thanks
If you use dreamweaver's designer view and paste your Arabic text in design view you will get ascii characters in dreamweaver's code view which will work in any web browser.
First, an important aside: check that the web service you are consuming sends you actual Arabic characters and not actual question marks. Check a network dump if you are not sure, and use wget/curl to perform a simple transaction; check the results.
If the raw data as sent by the WS is question marks, you have an uphill battle - try again and fiddle with the Accept/Accept-Charset headers. If all fail, it may be that the server itself isn't coded properly and there ain't much you can do after that...
Also, you're trying to decode the text, convert it from a byte representation to abstract characters.
This has been the problem Sending UTF-8 data from Android. Your code would work fine except that you will have to encode your String to Base64 . At Server PHP you just decode Base64 String back. It worked for me. I can share if you need the code.

Categories

Resources