 public extension String {
   
   static func fromCString
-    (cs: ConstUnsafePointer<CChar>, length: Int!) -> String?
+    (cs: UnsafePointer<CChar>, length: Int!) -> String?
   {
     if length == .None { // no length given, use \0 standard variant
       return String.fromCString(cs)
     }
     
     let buflen = length + 1
-    var buf    = UnsafePointer<CChar>.alloc(buflen)
+    var buf    = UnsafeMutablePointer<CChar>.alloc(buflen)
     memcpy(buf, cs, UInt(length))
     buf[length] = 0 // zero terminate
     let s = String.fromCString(buf)

import Darwin

// This allows you to do: str[str.startIndex..idx+4]
public func +<T: ForwardIndex>(idx: T, distance: T.DistanceType) -> T {
  return advance(idx, distance)
}
public func +<T: ForwardIndex>(distance: T.DistanceType, idx: T) -> T {
  return advance(idx, distance)
}

public func -<T: BidirectionalIndex where T.DistanceType : SignedInteger>
  (idx: T, distance: T.DistanceType) -> T
{
  var cursor = idx

    }
    
    var cstr = [CChar](count: data.count + 1, repeatedValue: 0)
    memcpy(&cstr, data, UInt(data.count))
    cstr[data.count] = 0 // 0-terminate
    
    return String.fromCString(cstr)!
  }
  
  func dataInCStringEncoding() -> [UInt8] {
    return self.withCString { (cstr: UnsafePointer<CChar>) in
      let len  = strlen(cstr)
      if len < 1 {
        return [UInt8]()
      }
      var buf = [UInt8](count: Int(len), repeatedValue: 0)
      memcpy(&buf, cstr, len)
      return buf
    }
  }
