microsoft

Replace Microsoft chars in JavaScript

Okay, so have you ever had a user call you up and say “the website is putting garbage into my notes” – and it turns out they are copying and pasting paragraphs from a Word document into the textarea on your site. Well, Microsoft Office apps use a special character set (Windows 1252) so they can have nice looking quotes, and longer dashes. Which all look very nice in the Word document, but when they are pasted into a textarea in your site, they are converted to weird characters.

There is a simple function you can use to replace them:

/**
 * Replace Word characters with Ascii equivalent
 **/
function replaceWordChars (text) {
    var s = text;
    // smart single quotes and apostrophe
    s = s.replace(/[\u2018|\u2019|\u201A]/g, "\'");
    // smart double quotes
    s = s.replace(/[\u201C|\u201D|\u201E]/g, "\"");
    // ellipsis
    s = s.replace(/\u2026/g, "...");
    // dashes
    s = s.replace(/[\u2013|\u2014]/g, "-");
    // circumflex
    s = s.replace(/\u02C6/g, "^");
    // open angle bracket
    s = s.replace(/\u2039/g, "");
    // spaces
    s = s.replace(/[\u02DC|\u00A0]/g, " ");

    return s;
}

Stick the above on an onblur event or something, and the problem has gone away. Until the next version of Office anyway…

Thanks to http://www.andornot.com/blog/post/Replace-MS-Word-special-characters-in-javascript-and-C.aspx for this lovely code.

MyODBC and Access – Urgh

Well. I have had to sort out a report for someone who likes using Microsoft Access.

We use the MySQL ODBC driver, called MyODBC Connector. But its relationship with Access is riddled with bugs. Can’t decide who to blame, but its pretty horrific.

So I created a blank Access database and connected the tables I required for my report. Alas, one of the fields has a name length of 16 or so characters, so this crashes Access completely. Great.

I made a copy of the MySQL table and renamed it to something shorter. This worked. So, I needed to alias the table somehow.

I created a VIEW in MySQL with a shorter name:

CREATE VIEW smallname SELECT * FROM longernamedtable;

I was able to link this in Access fine. Not a problem, however, all the VARCHAR fields in the view came out as chinese characters. AARGH

So, I managed to utililise the MERGE engine. Here goes:

CREATE TABLE smallname SELECT * FROM longernamedtable;
DELETE FROM smallname;
ALTER TABLE smallname ENGINE=MERGE;
ALTER TABLE smallname UNION=(longernamedtable);

Now, we have a mirrored table. Brilliant. It linked to Access fine, and the VARCHAR’s were back to normal.

Thought I would share that with you. Because this little problem was starting to drain all the life out of me…

 

PS. The tables need to be ISAM for this to work.

CSV file of Windows Process list

If you need a CSV file of the currently running  processes in Windows you can use the task manager command line tool.

C:> TASKLIST.EXE

This will dump the task list to the screen. But there are several options you can use:

C:> TASKLIST.EXE /V /FO CSV > filename.csv

The above will produce a nicely formatted CSV file with information about the process, such as CPU Time and memory used.

The full list of other options can be found at the Microsoft Technet library, well, until they move the location of it…¬†http://technet.microsoft.com/en-us/library/bb491010.aspx

 

Stupid Microsoft error messages

Why is it that the Microsoft developers have an inability to get their systems and processes to output a meaningful error message now and again? I mean, is it really that hard?

I try to stay away from company slagging, but Microsoft, really…?

I have recently bought an XBox 360 and I think its great. Had no crashes, and no problems with it, until I joined XBox Live. I was offered a month free – great. I used that, and then on the XBox dashboard, I noticed an advert for another free month. Double great. However, when I tried to activate this, I received a cryptic error message on the screen. Something like, “This operation failed. Error 8005342” – nothing else.

Great. I searched on Google, and found that many people had this error, and someone seemed to think that registering my credit card details, on www.xbox.com might be a good idea to try. I did this and re-attempted the procedure with success this time. So, why if the error is “no credit card details entered” – why the bloody hell doesn’t the error message say that??!?!

And just now, I was trying to install .Net framework 4 on a test PC. I receieved another message, “The install failed due to a fatal error”… Helpful. What if someone you know dies and all the doctor said was, “he died”. “Why?”, “He’s dead”

Helpful.

Turned out, I needed to install something called the Microsoft Windows Imaging Component. Again. Why not tell me this instead of “a fatal error”

Its no wonder people have so much trouble getting used to using a computer!!!

Sorry for the rant. Just pisses me off!

Installing Tahoma font in Ubuntu

The stylesheet of our intranet is primarily Tahoma, and Firefox on Ubuntu doesn’t look good.

To install the Microsoft Core Fonts package in Ubuntu, run the following in your terminal:

sudo apt-get install msttcorefonts

And then this should go away and get them. Lovely.

NB, if this doesn’t take immediate effect, you can rebuild the font cache by running

sudo fc-cache -fv

Now, the Tahoma font is excluded these days from this package, so you’ll need to install that one manually, by following the instructions found here

Installing Tahoma font in Ubuntu

The stylesheet of our intranet is primarily Tahoma, and Firefox on Ubuntu doesn’t look good.

To install the Microsoft Core Fonts package in Ubuntu, run the following in your terminal:

sudo apt-get install msttcorefonts

And then this should go away and get them. Lovely.

NB, if this doesn’t take immediate effect, you can rebuild the font cache by running

sudo fc-cache -fv

Now, the Tahoma font is excluded these days from this package, so you’ll need to install that one manually, by following the instructions found here