Get encoding of a file in Windows

Open up your file using regular old vanilla Notepad that comes with Windows. It will show you the encoding of the file when you click “Save As…“. It’ll look like this: Whatever the default-selected encoding is, that is what your current encoding is for the file. If it is UTF-8, you can change it to … Read more

How to convert Strings to and from UTF8 byte arrays in Java

Convert from String to byte[]: String s = “some text here”; byte[] b = s.getBytes(StandardCharsets.UTF_8); Convert from byte[] to String: byte[] b = {(byte) 99, (byte)97, (byte)116}; String s = new String(b, StandardCharsets.US_ASCII); You should, of course, use the correct encoding name. My examples used US-ASCII and UTF-8, two commonly-used encodings.

ArrayBuffer to base64 encoded string

function _arrayBufferToBase64( buffer ) { var binary = ”; var bytes = new Uint8Array( buffer ); var len = bytes.byteLength; for (var i = 0; i < len; i++) { binary += String.fromCharCode( bytes[ i ] ); } return window.btoa( binary ); } but, non-native implementations are faster e.g. https://gist.github.com/958841 see http://jsperf.com/encoding-xhr-image-data/6 Updated benchmarks: https://jsben.ch/wnaZC

What encoding/code page is cmd.exe using?

Yes, it’s frustrating—sometimes type and other programs print gibberish, and sometimes they do not. First of all, Unicode characters will only display if the current console font contains the characters. So use a TrueType font like Lucida Console instead of the default Raster Font. But if the console font doesn’t contain the character you’re trying … Read more

Replace non-ASCII characters with a single space

Your ”.join() expression is filtering, removing anything non-ASCII; you could use a conditional expression instead: return ”.join([i if ord(i) < 128 else ‘ ‘ for i in text]) This handles characters one by one and would still use one space per character replaced. Your regular expression should just replace consecutive non-ASCII characters with a space: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)