The Little Things

I remember once being told a long time ago that someone famous said that the littlest things mean the most. They were talking about people and how those small gestures and actions that we do for one another seem like nothing, but in fact mean everything. What do I mean? Well, squeezing someone’s hand a certain way…or a look across a room. Or even, putting an ‘x’ at the end of a message; that kind of thing.

I was thinking about that this week when I had a small problem where I wasn’t able to match against this string that appeared in a Word document:

The text I was searching for in a Word document - manager's name.

The text in MS Word

I was using Microsoft’s Open Office XML (OOXML) to strip out the cells from a series of tables and then convert them into a list of strings. How I did that isn’t important, but this is what I could see when I inspected the object in VS 2012:

Inspecting the object.

Inspecting the object.

And this is how I was trying to match against it:

In case you’re wondering why I didn’t just use something like IndexOf on the IEnumerable, it was important that I had the ability to search without considering the case: see line 19.

Then, for some reason, when I would do something like:

I kept getting a return value of -1 meaning it wasn’t finding an exact match. Humph.

I also tried things like:

and all combinations thereof. What made it all the more interesting was there are only two keys on my keyboard that look remotely like the apostrophe. Here’s one of them (the only one that really looks like it):

The apostrophe key on my keyboard.

The dreaded key.

Humph ^ 2.

Before continuing, take a few minutes to think about what might have been the cause of the problem.

I hate giving up but usually when this happens I leave it for a while and come back to it. I guess it’s a count to ten kind of thing when someone is angry, though of course, I’m not! In fact, I love this type of thing and this work generally because for me, it’s like a huge puzzle that I just have to crack.

This time though I asked a friend whilst I moved onto something else and after a while, he realised what the problem was. Let me show you what this text looks like when you paste it into Notepad++.

What the text looks like pasted and typed.

Text pasted into Notepad++ and typed below using the keyboard.

Can you hear me groaning? Clearly, not all apostrophes are made the same.

The culprit was Word and in particular, a feature which means it replaces any quotes with smart ones, though to be honest, it didn’t feel too smart at the time. The reason I didn’t notice this is that the change from what you type on the keyboard to the other unicode character is lightning fast. So much so, you don’t even notice it. Here they are for completeness:

To fix it (should you want to), this is what you need to do in the options of Word:

Instructions (highlighted) to turn off smart quotes in Word.

How to turn off smart quotes.

In summary, be careful when searching for quotes where Microsoft Word is involved because you never know when it might want to act in a smart way.

Obviously, then, this post exists to try and help someone else out should they run into this kind of issue, but there is another reason.

Apostrophes…especially the little ones…mean everything.

twittergoogle_plusredditpinteresttumblrmail

Written by Stephen Moon
email: stephen at logicalmoon.com
www: https://www.logicalmoon.com


This entry was posted in: c#. Bookmark the ➜ permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *