You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: GTMNSString+HTML.m
    path of file: ./repos/toggldesktop/third_party/plcrashreporter/Tools/google-toolbox-for-mac-trunk-r582/Foundation
    
    the code of the file until where you have to start completion: //
//  GTMNSString+HTML.m
//  Dealing with NSStrings that contain HTML
//
//  Copyright 2006-2008 Google Inc.
//
//  Licensed under the Apache License, Version 2.0 (the "License"); you may not
//  use this file except in compliance with the License.  You may obtain a copy
//  of the License at
// 
//  http://www.apache.org/licenses/LICENSE-2.0
// 
    
function for Bsearching table above
static int EscapeMapCompare(const void *ucharVoid, const void *mapVoid) {
  const unichar *uchar = (const unichar*)ucharVoid;
  const HTMLEscapeMap *map = (const HTMLEscapeMap*)mapVoid;
  int val;
  if (*uchar > map->uchar) {
    val = 1;
  } else if (*uchar < map->uchar) {
    val = -1;
  } else {
    val = 0;
  }
  return val;
}

@implementation NSString (GTMNSStringHTMLAdditions)

- (NSString *)gtm_stringByEscapingHTMLUsingTable:(HTMLEscapeMap*)table 
                                          ofSize:(NSUInteger)size 
                                 escapingUnicode:(BOOL)escapeUnicode {  
  NSUInteger length = [self length];
  if (!length) {
    return self;
  }
  
  NSMutableString *finalString = [NSMutableString string];
  NSMutableData *data2 = [NSMutableData dataWithCapacity:sizeof(unichar) * length];

  // this block is common between GTMNSString+HTML and GTMNSString+XML but
  // it's so short that it isn't really worth trying to share.
  const unichar *buffer = CFStringGetCharactersPtr((CFStringRef)self);
  if (!buffer) {
    // We want this buffer to be autoreleased.
    NSMutableData *data = [NSMutableData dataWithLength:length * sizeof(UniChar)];
    if (!data) {
      // COV_NF_START  - Memory fail case
      _GTMDevLog(@"couldn't alloc buffer");
      return nil;
      // COV_NF_END
    }
    [self getCharacters:[data mutableBytes]];
    buffer = [data bytes];
  }

  if (!buffer || !data2) {
    // COV_NF_START
    _GTMDevLog(@"Unable to allocate buffer or data2");
    return nil;
    // COV_NF_END
  }
  
  unichar *buffer2 = (unichar *)[data2 mutableBytes];
  
  NSUInteger buffer2Length = 0;
  
  for (NSUInteger i = 0; i < length; ++i) {
    HTMLEscapeMap *val = bsearch(&buffer[i], table, 
                                 size / sizeof(HTMLEscapeMap), 
                                 sizeof(HTMLEscapeMap), EscapeMapCompare);
    if (val || (escapeUnicode && buffer[i] > 127)) {
      if (buffer2Length) {
        CFStringAppend