package errors

import (
	
	
	
)

// ErrInvalidUTF8 reports invalid UTF-8 in a JSON string: jsontext and the v2 json package report it by this error.
var ErrInvalidUTF8 = errors.New("invalid UTF-8")

// maxShownPointer is the length over which the pointer of an error is shown shortened: its start and its end,
// of about half of it each, cut before a token if they can be.
const maxShownPointer = 100

// ShortPointer shortens a long pointer. The part which is left out is shown by an ellipsis for the end of the
// token which the start cuts, one for the whole tokens, and one for the start of the token which the end cuts.
func ( string) string {
	if len() <= maxShownPointer {
		return 
	}
	 := maxShownPointer / 2
	 := strings.LastIndexByte([1:], '/') + 1
	if  <= 0 {
		for  = ; !utf8.RuneStart([]); -- {
		}
	}
	 := max(len()-, +1)
	 := strings.IndexByte([:], '/')
	 :=  < 0 // the end starts within a token
	if  {
		for  = len() - ; !utf8.RuneStart([]); ++ {
		}
	} else {
		 += 
	}
	 := [:]
	 := [:]
	,  := strings.IndexByte(, '/'), strings.LastIndexByte(, '/')
	if  != 0 {
		 += "…" // the end of a token
	}
	if  >= 0 && ( >  || !) {
		 += "/…" // whole tokens
	}
	if  &&  >= 0 {
		 += "/"
		if  < len()-1 {
			 += "…" // the start of a token
		}
	}
	return  + [:]
}