Is the sequence of bytes in ns at position a valid Char ?

Returns either

  • 0 if valid
  • 1 if incomplete
  • 2 if invalid

Property definitions

core $ Codec :: is_valid_char
	# Is the sequence of bytes in `ns` at `position` a valid Char ?
	#
	# Returns either
	# * 0 if valid
	# * 1 if incomplete
	# * 2 if invalid
	fun is_valid_char(ns: CString, position: Int): Int is abstract
lib/core/codecs/codec_base.nit:54,2--60,63

core $ UTF8Codec :: is_valid_char
	redef fun is_valid_char(ns, len) do
		if len == 0 then return 2
		if not ns[0].is_valid_utf8_start then return 2
		for i in [1 .. len[ do if ns[i] & 0b1100_0000 != 0b1000_0000 then return 2
		if len != ns[0].u8len then return 1
		return 0
	end
lib/core/codecs/utf8.nit:54,2--60,4

core $ ISO88591Codec :: is_valid_char
	redef fun is_valid_char(ns, len) do
		return 0
	end
lib/core/codecs/iso8859_1.nit:62,2--64,4