func FromUTF16Column(p Point, chr int, content []byte) (Point, error) {
	if !p.HasOffset() {
		return Point{}, fmt.Errorf("FromUTF16Column: point is missing offset")
	}
	// if chr is 1 then no adjustment needed
	if chr <= 1 {
		return p, nil
	}
	if p.Offset() >= len(content) {
		return p, fmt.Errorf("offset (%v) greater than length of content (%v)", p.Offset(), len(content))
	}
	remains := content[p.Offset():]
	// scan forward the specified number of characters
	for count := 1; count < chr; count++ {
		if len(remains) <= 0 {
			return Point{}, fmt.Errorf("FromUTF16Column: chr goes beyond the content")
		}
		r, w := utf8.DecodeRune(remains)
		if r == '\n' {
			return Point{}, fmt.Errorf("FromUTF16Column: chr goes beyond the line")
		}
		remains = remains[w:]
		if r >= 0x10000 {
			// a two point rune
			count++
			// if we finished in a two point rune, do not advance past the first
			if count >= chr {
				break
			}
		}
		p.v.Column += w
		p.v.Offset += w
	}
	return p, nil
}
// FromUTF16Column advances the point by the utf16 character offset given the
// supplied line contents.
// This is used to convert from the utf16 counts used by some editors to the
// native (always in bytes) column representation.
FromUTF16Column advances the point by the utf16 character offset given the
supplied line contents.
This is used to convert from the utf16 counts used by some editors to the
native (always in bytes) column representation.
// FromUTF16Column advances the point by the utf16 character offset given the // supplied line contents . // This is used to convert from the utf16 counts used by some editors to the // native ( always in bytes ) column representation .
func FromUTF16Column(p Point, chr int, content []byte) (Point, error) {
	if !p.HasOffset() {
		return Point{}, fmt.Errorf("FromUTF16Column: point is missing offset")
	}
	if chr <= 1 {
		return p, nil
	}
	if p.Offset() >= len(content) {
		return p, fmt.Errorf("offset (%v) greater than length of content (%v)", p.Offset(), len(content))
	}
	remains := content[p.Offset():]
	for count := 1; count < chr; count++ {
		if len(remains) <= 0 {
			return Point{}, fmt.Errorf("FromUTF16Column: chr goes beyond the content")
		}
		r, w := utf8.DecodeRune(remains)
		if r == '\n' {
			return Point{}, fmt.Errorf("FromUTF16Column: chr goes beyond the line")
		}
		remains = remains[w:]
		if r >= 0x10000 {
			count++
			if count >= chr {
				break
			}
		}
		p.v.Column += w
		p.v.Offset += w
	}
	return p, nil
}
func FromUTF16Column ( p Point , chr int , content [ ] byte ) ( Point , error ) { if ! p . HasOffset ( ) { return Point { } , fmt . Errorf ( " " ) } if chr <= 1 { return p , nil } if p . Offset ( ) >= len ( content ) { return p , fmt . Errorf ( " " , p . Offset ( ) , len ( content ) ) } remains := content [ p . Offset ( ) : ] for count := 1 ; count < chr ; count ++ { if len ( remains ) <= 0 { return Point { } , fmt . Errorf ( " " ) } r , w := utf8 . DecodeRune ( remains ) if r == '\n' { return Point { } , fmt . Errorf ( " " ) } remains = remains [ w : ] if r >= 0x10000 { count ++ if count >= chr { break } } p . v . Column += w p . v . Offset += w } return p , nil }
FromUTF16Column advances the point by the utf16 character offset given the
supplied line contents.
FromUTF16Column advances the point by the utf16 character offset given the supplied line contents .
// if chr is 1 then no adjustment needed // scan forward the specified number of characters // a two point rune // if we finished in a two point rune, do not advance past the first