C# ushort[] to string conversion

Standard

P/Invoke can actually handle what you’re after most of the time using StringBuilder to create writable buffers, for example see pinvoke.net on GetWindowText and related functions.

However, that aside, with data as ushort, I assume that it is encoded in UTF-16LE. If that is the case you can use Encoding.Unicode.GetString(), but that will exepect a byte array rather than a ushort array. To turn your ushorts into bytes, you can allocate a separate byte array and use Buffer.BlockCopy, something like this:

ushort[] data = new ushort[10];
for (int i = 0; i < data.Length; ++i)
    data[i] = (char) ('A' + i);

string asString;
byte[] asBytes = new byte[data.Length * sizeof(ushort)];
Buffer.BlockCopy(data, 0, asBytes, 0, asBytes.Length);
asString = Encoding.Unicode.GetString(asBytes);

However, if unsafe code is OK, you have another option. Get the start of the array as a ushort*, and hard-cast it to char*, and then pass it to the string constructor, like so:

string asString;
unsafe
{
    fixed (ushort *dataPtr = &data[0])
        asString = new string((char *) dataPtr, 0, data.Length);
}

The Google Play Music Website Now Has A Nifty ‘Particles’ Visualizer

Standard

The web browser version of Google Play Music isn’t exactly full-featured – it pales in comparison even to built-in tools like Windows Media Player or iTunes. But now it has one more tool that’s bringing it a little closer: a visualizer. A visualizer is an overlay that presets a visual accompaniment to a musical track. Some of them get pretty elaborate, some of them aren’t much more than a graphic equalizer. Google Play Music’s first visualizer is called “Particles.”

Continue reading

RemoteIE: running IE everywhere, what we have all been waiting for : D

Standard

Today, we’re excited to announce the preview availability of RemoteIE via Azure RemoteApp. This is a free service from Microsoft that allows you to run the latest version of Internet Explorer on the Windows 10 Technical Preview from your Windows, Mac OS X, iOS or Android devices, without the need to run a new OS or heavyweight virtual machine on your device. Going forward, this will be the recommended way for developers who are not running Windows 10 to test the latest IE preview versions.

Continue reading

Brad Woodhouse: Ball’s in your court, Speaker Boehner

Standard
Speaker Boehner. What a character.

Last night, the President announced he’s taking decisive Executive Action to begin responsibly dealing with the broken immigration system.  For months, the President warned House Republicans that if they didn’t act, he would.  There is just too much at stake with millions of people living in the shadows and in fear of being separated from their families.

Continue reading

Movie News

Standard
THE HUNGER GAMES: MOCKINGJAY – PART 1

Sure, it makes business sense to stretch the Hunger Games series as far as it can go — but does it make artistic sense? Critics say the answer is a tentative yes; while The Hunger Games: Mockingjay – Part 1 is decidedly short on action, its exceptional cast and intriguing ideas still make for compelling viewing. War is brewing throughout the land, and the skill and compassion that Katniss (Jennifer Lawrence) has displayed in the Hunger Games has made her a folk hero for the rebellion. But while Katniss is uncomfortable in her new role as a symbol, she teams with a band of rebels in order to ensure her family’s safety and rescue her old partner Peeta (Josh Hutcherson) from the Capital. The pundits say The Hunger Games: Mockingjay – Part 1 provides a deeper look into the trials and tribulations of District 13, even if it sometimes feels like an extended cliffhanger for the final chapter.

Continue reading

Bad Juju Games acquires Desura from Linden Lab, Answers from Co-Founder

Standard

Can you talk about your plans to make Desura a more competitive platform to Steam? Whever I read post-mortems/sales breakdowns, it almost always seems like Steam generates sooo many more sales that Desura isn’t worth publishing on, much less fully integrating. This saddens me, because competition is good, but I’m not sure how tractable the issue really is.

Continue reading