         }
 
         var lines: [Line] {
-            return rangeLinePairs.map { $0.line }
+            return rangesAndLine.map { $0.line }
         }
 
         func lineAndCharacterForCharacterOffset(offset: Int) -> (line: Int, character: Int)? {
-            let index = rangeLinePairs.indexOf { NSLocationInRange(offset, $0.range) }
+            let index = rangesAndLine.indexOf { NSLocationInRange(offset, $0.range) }
             return index.map {
-                let pair = rangeLinePairs[$0]
-                return (line: pair.line.index, character: offset - pair.range.location + 1)
+                let element = rangesAndLine[$0]
+                return (line: element.line.index, character: offset - element.range.location + 1)
+            }
+        }
+        
+        func lineAndCharacterForByteOffset(offset: Int) -> (line: Int, character: Int)? {
+            let index = rangesAndLine.indexOf { NSLocationInRange(offset, $0.byteRange) }
+            return index.map {
+                let element = rangesAndLine[$0]
+                return (line: element.line.index, character: offset - element.range.location + 1)
             }
         }
     }

    - parameter offset: byte offset.
    */
    public func lineAndCharacterForByteOffset(offset: Int) -> (line: Int, character: Int)? {
        return byteRangeToNSRange(start: offset, length: 0).flatMap { characterRange in
            return lineAndCharacterForCharacterOffset(NSMaxRange(characterRange))
        }
    }

    /**

            let index: String.UTF8Index
        }

        struct RangesAndLine {
            let range: NSRange
            let byteRange: NSRange
            let line: Line
        }

        var byteOffsetIndexPairs = Dictionary<Int, ByteOffsetIndexPair>()
        let rangesAndLine: [RangesAndLine]
        let utf8View: String.UTF8View

        init(_ string: NSString) {
