func ToUTF16Column(p Point, content []byte) (int, error) {
	offset := p.Column()
	if content == nil {
		return -1, fmt.Errorf("ToUTF16Column: missing content")
	}
	if !p.HasPosition() {
		return -1, fmt.Errorf("ToUTF16Column: point is missing position")
	}
	if p.HasOffset() {
		offset = p.Offset()
	}
	col := p.Column()
	if col == 1 {
		// column 1, so it must be chr 1
		return 1, nil
	}
	// work out the offset at the start of the line using the column
	lineOffset := offset - (col - 1)
	if lineOffset < 0 || offset > len(content) {
		return -1, fmt.Errorf("ToUTF16Column: offsets %v-%v outside file contents (%v)", lineOffset, offset, len(content))
	}
	// use the offset to pick out the line start
	start := content[lineOffset:]
	// now truncate down to the supplied column
	start = start[:col]
	// and count the number of utf16 characters
	// in theory we could do this by hand more efficiently...
	return len(utf16.Encode([]rune(string(start)))), nil
}
// ToUTF16Column calculates the utf16 column expressed by the point given the
// supplied file contents.
// This is used to convert from the native (always in bytes) column
// representation and the utf16 counts used by some editors.
ToUTF16Column calculates the utf16 column expressed by the point given the
supplied file contents.
This is used to convert from the native (always in bytes) column
representation and the utf16 counts used by some editors.
// ToUTF16Column calculates the utf16 column expressed by the point given the // supplied file contents . // This is used to convert from the native ( always in bytes ) column // representation and the utf16 counts used by some editors .
func ToUTF16Column(p Point, content []byte) (int, error) {
	offset := p.Column()
	if content == nil {
		return -1, fmt.Errorf("ToUTF16Column: missing content")
	}
	if !p.HasPosition() {
		return -1, fmt.Errorf("ToUTF16Column: point is missing position")
	}
	if p.HasOffset() {
		offset = p.Offset()
	}
	col := p.Column()
	if col == 1 {
		return 1, nil
	}
	lineOffset := offset - (col - 1)
	if lineOffset < 0 || offset > len(content) {
		return -1, fmt.Errorf("ToUTF16Column: offsets %v-%v outside file contents (%v)", lineOffset, offset, len(content))
	}
	start := content[lineOffset:]
	start = start[:col]
	return len(utf16.Encode([]rune(string(start)))), nil
}
func ToUTF16Column ( p Point , content [ ] byte ) ( int , error ) { offset := p . Column ( ) if content == nil { return - 1 , fmt . Errorf ( " " ) } if ! p . HasPosition ( ) { return - 1 , fmt . Errorf ( " " ) } if p . HasOffset ( ) { offset = p . Offset ( ) } col := p . Column ( ) if col == 1 { return 1 , nil } lineOffset := offset - ( col - 1 ) if lineOffset < 0 || offset > len ( content ) { return - 1 , fmt . Errorf ( " " , lineOffset , offset , len ( content ) ) } start := content [ lineOffset : ] start = start [ : col ] return len ( utf16 . Encode ( [ ] rune ( string ( start ) ) ) ) , nil }
ToUTF16Column calculates the utf16 column expressed by the point given the
supplied file contents.
ToUTF16Column calculates the utf16 column expressed by the point given the supplied file contents .
// column 1, so it must be chr 1 // work out the offset at the start of the line using the column // use the offset to pick out the line start // now truncate down to the supplied column // and count the number of utf16 characters // in theory we could do this by hand more efficiently...