Golang unicode.ReplacementChar Constant with Examples

Golang | unicode.ReplacementChar Constant: Here, we are going to learn about the ReplacementChar constant of the unicode package with its usages, syntax, and examples.
Submitted by IncludeHelp, on September 15, 2021

unicode.ReplacementChar Constant

The ReplacementChar constant is an inbuilt constant of the unicode package which is used to represent invalid code points. The value of ReplacementChar constant is '\uFFFD'.

Syntax:

int32 unicode.ReplacementChar

Parameter(s):

  • None

Return Value:

The return type of the unicode.ReplacementChar constant is an int32, it returns the represents invalid code points value.

Example 1:

// Golang program to demonstrate the
// example of unicode.ReplacementChar constant

package main

import (
	"fmt"
	"unicode"
)

func main() {
	fmt.Printf("Value of unicode.ReplacementChar: %U\n",
		unicode.ReplacementChar)
	fmt.Printf("Type of unicode.ReplacementChar: %T\n",
		unicode.ReplacementChar)
}

Output:

Value of unicode.ReplacementChar: U+FFFD
Type of unicode.ReplacementChar: int32

Example 2:

// Golang program to demonstrate the
// example of unicode.ReplacementChar constant

package main

import (
	"fmt"
	"unicode"
)

// creating function to return the
// value of ReplacementChar.
func getReplacementChar() int32 {
	return unicode.ReplacementChar
}

func main() {
	fmt.Println("Value of unicode.ReplacementChar:",
		getReplacementChar())

	// Print the value in Unicode format
	fmt.Printf("Value of unicode.ReplacementChar: %U",
		getReplacementChar())
}

Output:

Value of unicode.ReplacementChar: 65533
Value of unicode.ReplacementChar: U+FFFD

Golang unicode Package »




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.