So, this is probably a really, really stupid question. :/ Sorry about that, I'm a total newbie. Um, I'm getting a lot of "invalid byte sequence in UTF-8" type errors. I found a solution here (scroll down for the +24 one), but I have no idea how to actually implement it. Do I type it in the head of the affected files? Do I have to install anything else? Also, which solution is better, the ignore one or the double-encoding one?
Also bonus noob question! The code I'm fiddling with now is actually shared code, which means that it's presumably worked for a lot of other people without the UTF-8 problem. Any idea why my computer especially seems to be unable to get it working? Thanks.
Just put
# encoding: utf-8
on the very first line of affected files.
Related
I am having a hard time to load a textfile into a stringlist in firemonkey on osx when the encoding of the textfile in not known.
When I just use list.loadfromfile(filename), I get most of the time an exception regarding encoding.
list.loadfromfile(filename,TEncoding.unicode) will also fail when the file is in ansi, and opposite.
There is no issue on Windows, list.loadfromfile(filename) just works, but not on osx.
I cant specify the encoding, because it will be unknown (user provide the text files).
Any clue how I can get around this encoding issue when running the app on a mac?
In general this is not possible. It is quite possible to create a single file that is valid when interpreted in all common encodings. This has been discussed many times, for instance: The Notepad file encoding problem, redux.
I'm assuming that you are working with files that do not contain byte order marks, BOMs. Obviously if your input files contained BOMs then you could simply check the BOM and be done.
With that assumption stated, the right solution to the problem, in a perfect world, is to know the encoding. Either pick a specific encoding which your program requires, or arrange for the user to tell you the encoding when they supply the file.
If, for whatever reason, you cannot do that then the next best thing to do is to use heuristics to attempt to guess the encoding used. I'm not aware of any Pascal code to do this. But you should be able to put something together that will work reasonably well. This answer gives an outline of a basic strategy: https://stackoverflow.com/a/20747074
I have been doing some tests with the path loss formula and it gives me some pretty good results so far. However, I looked at the original code and saw that the formula used is
distance = Math.pow(10.0, ((-adjustedRssi+txPower)/10*0.35))
where adjustedRssi is RSSI - adjustment. This was giving me very small values for distance so I thought that I must have modified it at some point by accident. After doing the maths and playing around a bit I found that using txPower-adjustment instead of txPower-adjustedRSSI gives me correct distances.
I figured that the error must have been my fault but looking back at an original copy of the library I am seeing that the formula was actually this way all along.
Is this a mistake or am I missing something obvious? Using the formla as is right now gives me wrong results while modifying it the way I did gives right results.
Also, why is the formula only used if the ratio<1. Shouldn't it work in either case?
Yes, you are absolutely right! Reviewing this now, I can see that this was a simple coding error I made when I originally wrote this. I paused work on the path loss formula because I was getting poor results, probably because of this error.
Since this is a development branch of an open source library hosted on Github, it is probably most appropriate to discuss this in that forum. Please feel free to comment directly on the pull request thread here: https://github.com/AltBeacon/android-beacon-library/pull/251. As the lead developer on that project, I would also welcome a pull request with the changes you are making.
Is there an option to group, or sort the hints and warnings messages by some criteria (e.g get all "Variable might not have been initialized" in a group under the messages window)?
Using the IDE, there isn't. You can't do it using the command-line compiler either.
One possible solution is to disable all warnings except one in the compiler settings/options under hints and warnings tab and so forth but this takes waaaayyy too long to do !
However if you really need this functionality on a daily basis for a large project, there is the possibility of saving this to an "option set" and then re-applying that when needed.
Haven't tried this myself yet, but good chance this will work.
Will try now because I need this =D
Hmm I discovered a little trick, it's enough to just press F and it will set it to False ! ;)
This will speed up the process ! ;)
OK Just tried it, it's a 50% solution.
Unfortunately hints are an all or nothing kind of thing, cannot be specified seperately :(
I've programmed 2 rails apps so far that have definitely gotten me pretty comfortable with ruby + rails. I can't say the same about C though. I don't even know what I'm looking at to be honest any time I look at C. It looks like macaroni.
I'm trying to build a spotify web app. The web API sucks, so I have to use this: https://developer.spotify.com/technologies/libspotify/
Documentation: https://developer.spotify.com/technologies/libspotify/docs/12.1.45/
Someone told me I can look at SWIG as a wrapper to communicate with rails.
The data I'm trying to get is 3 things: Number of subscribers, playlist thumbnail, number of tracks... given a playlist URL in the format of: http://open.spotify.com/user/{{username}}/playlist/{{playlist_id}}
To be honest, I have no idea where to even start. I can't find any swig tutorials online, and staring at this documentation isn't helping.
Could someone maybe give me a very brief 1,2,3 step procedure that one might go through to do something like this? I don't really expect any code.. but.. this is very roughly what I understand so far.. perhaps someone could help me fill this in..
save all C files you need to rails lib directory
compile files with ... ?
use swig somehow
:|
Any help would be super appreciated. I realize this is vague and 'subjective' but I don't even know how to ask this objectively. Just a quick 1-2-3-4-5 to get me started so I can do some googling would be fantastic.
Edit: I did find this, but this seems to be much obsolete: https://github.com/sarnesjo/greenstripes
Well, this is certainly not the answer but just thought to gather some related links here.
http://www.eqqon.com/index.php/Ruby_C_Extension_API_Documentation_(Ruby_1.8)
http://java.ociweb.com/mark/programming/Ruby_C_Extensions.pdf
http://people.apache.org/~rooneg/talks/ruby-extensions/ruby-extensions.html
Let us know about any update.
After some digging I have found this. I think this is the answer for my ruby libspotify wrapper: https://github.com/Burgestrand/Hallon
Old days are catching up and old stuff isn't as good as new. Have tons of data stored in a system that only supports printing to ESC/P2 printer language, and even if that isn't completely unsupported, I want to be able to convert the printouts.
The datastorage is a properitary file. I have decoded some of the fileformat, but still there is too many blanks to successfully recreating the stored data.
The software is written in Forth. Tried to debug it, but it's too timeconsuming without a better decompiler. Any pointers...?
At last, the easy way out is to grab the printout stream and decode it into bitmaps and then create a PDF or something. Even if ESC/P2 is older I havent found a good library for it. Any pointers?
If anyone has suggestions to what path to walk I'd be very happy. Oh, and any software I write to solve this will be written in C#. :)