StreamExtensionIsUtf8 Method
Tests whether the specified section of
stream that extends
at least
count decoded characters from the current
Position is UTF-8 text. The method includes the byte order mark (BOM) in the check.
Namespace: FolkerKinzel.StringsAssembly: FolkerKinzel.Strings (in FolkerKinzel.Strings.dll) Version: 9.4.0+10a7d4d71aa960998e32ac0ac6c4fcbe4164c917
public static bool IsUtf8(
this Stream stream,
int count = 255,
bool leaveOpen = false
)
<ExtensionAttribute>
Public Shared Function IsUtf8 (
stream As Stream,
Optional count As Integer = 255,
Optional leaveOpen As Boolean = false
) As Boolean
public:
[ExtensionAttribute]
static bool IsUtf8(
Stream^ stream,
int count = 255,
bool leaveOpen = false
)
[<ExtensionAttribute>]
static member IsUtf8 :
stream : Stream *
?count : int *
?leaveOpen : bool
(* Defaults:
let _count = defaultArg count 255
let _leaveOpen = defaultArg leaveOpen false
*)
-> bool
- stream Stream
- The Stream to test.
- count Int32 (Optional)
- The minimum number of characters to check. If count is larger than stream has data, stream
is examined beginning from the current Position until EOF.
If the parameter is passed a negative number or if count is greater
than the length of the data in stream, stream is checked from the current position until EOF. If 0 is passed to the parameter,
the method only checks the byte order mark (BOM).
- leaveOpen Boolean (Optional)
- true to leave the stream open after the method has
finished; otherwise, false.
Booleantrue if the checked stream section represents UTF-8 text,
false
otherwise. In any case, if the method finds a UTF-8 BOM, it returns
true.
If
count is
0 and no UTF-8 BOM is found,
false
is returned.In Visual Basic and C#, you can call this method as an instance method on any object of type
Stream. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).