Class TruffleString.ToValidStringNode
java.lang.Object
com.oracle.truffle.api.nodes.Node
com.oracle.truffle.api.strings.TruffleString.ToValidStringNode
- All Implemented Interfaces:
NodeInterface, Cloneable
- Enclosing class:
TruffleString
Node to replace all invalid bytes in a given string, such that the resulting string is
valid
. See
execute(AbstractTruffleString, TruffleString.Encoding)
for details.- Since:
- 23.1
-
Nested Class Summary
Nested classes/interfaces inherited from class Node
Node.Child, Node.Children
-
Method Summary
Modifier and TypeMethodDescriptioncreate()
Create a newTruffleString.SwitchEncodingNode
.abstract TruffleString
execute
(AbstractTruffleString a, TruffleString.Encoding expectedEncoding) Returns a version of stringa
that contains only valid codepoints, which may be the string itself or a converted version.Get the uncached version ofTruffleString.SwitchEncodingNode
.Methods inherited from class Node
accept, adoptChildren, atomic, atomic, copy, deepCopy, getChildren, getCost, getDebugProperties, getDescription, getEncapsulatingSourceSection, getLock, getParent, getRootNode, getSourceSection, insert, insert, isAdoptable, isSafelyReplaceableBy, notifyInserted, onReplace, replace, replace, reportPolymorphicSpecialize, reportReplace, toString
-
Method Details
-
execute
public abstract TruffleString execute(AbstractTruffleString a, TruffleString.Encoding expectedEncoding) Returns a version of stringa
that contains only valid codepoints, which may be the string itself or a converted version. Invalid byte sequences are replaced with'�'
(for UTF-*) or'?'
. This is useful for string sanitization in all uses cases where a string is required to actually bevalid
, such as libraries that actively reject broken input, network and file system I/O, etc.- Since:
- 23.1
-
create
Create a newTruffleString.SwitchEncodingNode
.- Since:
- 23.1
-
getUncached
Get the uncached version ofTruffleString.SwitchEncodingNode
.- Since:
- 23.1
-