Documentation
¶
Overview ¶
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Copyright Consensys Software Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Index ¶
Constants ¶
const ( // FORMAT_NONE indicates an empty format string FORMAT_NONE uint = iota // FORMAT_DEC indicates to format in decimal FORMAT_DEC // FORMAT_HEX indicates to format in hexadecimal FORMAT_HEX // FORMAT_BIN indicates to format in binary FORMAT_BIN // FORMAT_CHR indicates to format as a single ASCII character. The // argument is required (at type-check time) to be a concrete u8; the // rendered output is the single byte interpreted as a character. FORMAT_CHR )
Variables ¶
var EMPTY_FORMAT = Format{Code: FORMAT_NONE}
EMPTY_FORMAT indicates no formatted argument is required.
Functions ¶
func EscapeFormattedText ¶
EscapeFormattedText takes a string and escapes any characters which need to be escaped in order to be printed.
Types ¶
type Format ¶
Format simply encodes the set of permitted formatting strings in a printf statement, such as "%d", "%x", "%08x", "%8x", etc. Width specifies an optional minimum number of digits to render, and ZeroPad selects between zero-padding ('0' flag) and space-padding (the default). Any base prefix ("0x", "0b") is rendered separately and does not count towards Width.
func CharFormat ¶
func CharFormat() Format
CharFormat constructs a new character format. %c does not support width/zero-padding flags; the parser rejects them before this is reached.
func (Format) Render ¶
Render formats the given (non-negative) integer value according to this format, applying the selected base, then any minimum width and padding. This is the shared rendering used by the machine interpreters when producing debug / printf output, ensuring the reference word machine and the bytecode interpreter agree on the exact text emitted.