header

Torsten Curdt’s weblog

Service to convert to HTML entities

Lately I was looking for nice way to convert special characters to their entity equivalent. Of course there are editors out there that can do this for you. But what if I need this inside a textarea form field in my browser? You would have to cut-and-past it back and forth. Works – but is not convenient. Actually this one of the areas where one of the most forgotten OSX feature -a service- would be good.

The HTML Character Converter does exactly that. But frankly speaking I did not want to pay any money for something that simple. So I thought it would be a good exercise to get a bit more into Cocoa and Objective-C. The Apple “SimpleService” example was good starting point …but a mate of mine showed me a much easier and supposedly better way. The general idea is the same though. You have a function that acts as a service that can be executed from any program (if applicable). So first we define the service itself.


@interface QuotingServiceProvider : NSObject {
}

- (void)doQuotingService:(NSPasteboard *)pboard
                userData:(NSString *)data
                   error:(NSString **)error;

Opposed to what the Apple example does we don’t tinker with main() function though. We let the nib create the service as a custom class. Once the application has finished launching we have it self register as a service.


 - (void)applicationDidFinishLaunching:(NSNotification *)notification {
        [NSApp setServicesProvider:self];
 }

One thing that is common and required for both approaches is that you have to “announce” your service in the Info.plist file by adding a section like this.


<key>NSServices</key>
<array>
        <dict>
                <key>NSMenuItem</key>
                <dict>
                        <key>default</key>
                        <string>Quote String</string>
                </dict>
                <key>NSMessage</key>
                <string>doQuotingService</string>
                <key>NSPortName</key>
                <string>QuotingService</string>
                <key>NSReturnTypes</key>
                <array>
                        <string>NSStringPboardType</string>
                </array>
                <key>NSSendTypes</key>
                <array>
                        <string>NSStringPboardType</string>
                </array>
        </dict>
</array>

Have a look at the “doCapitalizeService” in Apple’s “SimpleService” to get an idea how to access and then return the modified data. From there it’s easy …but probably not really worth finishing. As it turns out there is already something that does exactly that for free. Just install the UnicodeChecker. It’s an incredible useful tool if you have to tinker with all different kind of encodings …and it also provides a service “Unicode <-> HTML entities”.

Nikon vs Canon – the quest for the perfect SLR

Nicanon D230For quite some time now I have been reading up on the current SLR situation. Being frustrated with the limitations of my small Canon IXUS – I want a SLR again! …a new digital one of course. When Nikon revealed the D200 my first reaction was – that’s my new camera!!! …but is it? Reading through all theses reviews was quite disappointing …for a couple of reasons.

Noise and the other noise

I know what I like – and what I dislike. I like low light shooting. I dislike using a flash. Now there have been some reviews comparing low light shots of the Nikon D200 and the Canon 30D. You can easily spot it. Bummer! The Canon performs much better in that respect. So back to the research …more reviews, more opinions and – more noise. This time in terms of information. It’s amazing how enthusiastic and biased …well, religious people can be when it comes down to picking either – Canon or Nikon. This leads to so many useless comments out there that finding valuable information becomes an daunting quest. Especially when you hear people from both “parties” stating the same – just for the other vendor: “[Canon|Nikon] does the better lenses!” Is the Canon stabilizer technology really better?
Even worse you sometimes get completely contradictory information. Now is the battery life for the D200 good or not? Some people claim it just takes some time for the battery to get trained …and then it is actually quite good! …but (at least) as many people say it doesn’t last long. Even opinions in magazines seem not to be consistent.

Nothing is perfect

Is it really that hard? Why can’t they build what I (and probably many others) would prefer. Sometimes I think they do this so they have something left to improve …for the upsale. And this is not at all just tied to SLRs – this very well applies to mobiles and even software! But let’s dream for a moment. So my SLR would look like this little mockup. Let’s call it Nicanon D230:

  • The solid body like the D200, a few buttons can go as it has the wheel of the Canon.
  • What is optional and only externally available at the moment will be integrated directly into the camera – a GPS receiver for geo tagging the photos.
  • It has the autofocus mode selector as an individual switch like the D200.
  • The menu structure of the D200.
  • The full size sensor of the Canon 5D,
  • so also a big viewfinder like my analog SLR had.
  • I also prefer the speed/appature display of the Nikon
  • but like the highlighted autofocus points in the Canon viewfinder
  • The speed of the 30D.
  • The battery monitoring of D200.
  • No crappy presets like everything below the Canon 5D/Nikon D200! I want to define them.
  • Well, and from some other vendor I would steel^^^borrow the in-body picture stabilizer that even removes dust from the sensor.
  • Not sure what lenses should fit onto it just yet, but…
  • the price of the Canon 350D would be nice :-D

A bit realistically the Canon 5D would probably be what would suite me most. But I am way too much of a rusty amature to spend that amount of money on a camera body. Especially as one should rather spend more money on the glas instead.

What to do …what to do?

Bye bye baby

Mitsubishi Magna Executive 2.6It’s really weird… To be honest I was really stressed out lately by the fact that I am now leaving really soon – and still had to get rid of some things. My car was one of them. Now I’ve sold it yesterday and feel a bit sad. *snief* But well, what can you do… Was good to have one. In some countries you just cannot really live without it. As so many other things selling a car is quite different down here. You have to get a special certificate in order to sell it. I am pretty sure they ripped me off when I had to get the road worthy. Some things seem to be cross-country – unfortunately.

Kermit on Daily Show

The Muppets! I’ve loved them when I was a kid – and I still love them. The films always had a bit too much of these singing scenes. But still – some parts were just sooo funny. One thing that I never understood …I cannot recall how often some other shows were rerun over the past years – why not the Muppet Show? Anyway – seems like there is hope left! …here is something that I came across and made me lough really hard. Enjoy.

Open Source from Apple

I am not sure whether this can be counted as a break through, but it’s good see they are heading this direction. Apple just open sourced the following projects. They are all licensed under Apache Software License.

Especially this one sentence in the announcement post on the mailinglist sounds promising.

Apple is more excited than ever about the power of Open Source development to create value for our (and your) products and customers