terraform/vendor/github.com/dimchansky/utfbom
Radek Simko f3357aad45
vendor: Downgrade Azure dependencies
This is to allow Terraform providers to upgrade to at least
one more minor version of the plugin SDK without major UX hiccups.

This concludes (unsuccessful) experiments involving upgrades
to SDK with https://github.com/Azure/go-autorest/pull/455

Even with that patch all providers still experience broken UX
as described in https://github.com/hashicorp/terraform/pull/22490

This downgrade reduces the uncomfort to only a handful of providers
from >100s. The affected providers more or less directly depend on
Azure SDK(s), which is ~8.

Affected providers practically cannot consume Terraform Plugin SDK
with this patch (downgraded Azure SDKs) and can just wait for
extracted Terraform Plugin SDK which is planned to be released soon.

This reverts the following PRs:

 - https://github.com/hashicorp/terraform/pull/22247
 - https://github.com/hashicorp/terraform/pull/22248
 - https://github.com/hashicorp/terraform/pull/22524
 - https://github.com/hashicorp/terraform/pull/22525

and it is otherwise result of the following commands

```
go get github.com/Azure/azure-sdk-for-go@v21.3.0
go get github.com/hashicorp/go-azure-helpers@166dfd221bb2
go mod tidy
```
2019-08-20 15:52:11 +01:00
..
.gitignore backend/azurerm: upgrading the SDK / support for proxies (#19414) 2018-11-21 22:06:03 +01:00
.travis.yml vendor: Downgrade Azure dependencies 2019-08-20 15:52:11 +01:00
LICENSE backend/azurerm: upgrading the SDK / support for proxies (#19414) 2018-11-21 22:06:03 +01:00
README.md vendor: Downgrade Azure dependencies 2019-08-20 15:52:11 +01:00
go.mod backend/azurerm: upgrading the SDK / support for proxies (#19414) 2018-11-21 22:06:03 +01:00
utfbom.go vendor: Downgrade Azure dependencies 2019-08-20 15:52:11 +01:00

README.md

utfbom Godoc License Build Status Go Report Card Coverage Status

The package utfbom implements the detection of the BOM (Unicode Byte Order Mark) and removing as necessary. It can also return the encoding detected by the BOM.

Installation

go get -u github.com/dimchansky/utfbom

Example

package main

import (
	"bytes"
	"fmt"
	"io/ioutil"

	"github.com/dimchansky/utfbom"
)

func main() {
	trySkip([]byte("\xEF\xBB\xBFhello"))
	trySkip([]byte("hello"))
}

func trySkip(byteData []byte) {
	fmt.Println("Input:", byteData)

	// just skip BOM
	output, err := ioutil.ReadAll(utfbom.SkipOnly(bytes.NewReader(byteData)))
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println("ReadAll with BOM skipping", output)

	// skip BOM and detect encoding
	sr, enc := utfbom.Skip(bytes.NewReader(byteData))
	var encStr string
	switch enc {
	case utfbom.UTF8:
		encStr = "UTF8"
	case utfbom.UTF16BigEndian:
		encStr = "UTF16 big endian"
	case utfbom.UTF16LittleEndian:
		encStr = "UTF16 little endian"
	case utfbom.UTF32BigEndian:
		encStr = "UTF32 big endian"
	case utfbom.UTF32LittleEndian:
		encStr = "UTF32 little endian"
	default:
		encStr = "Unknown, no byte-order mark found"
	}
	fmt.Println("Detected encoding:", encStr)
	output, err = ioutil.ReadAll(sr)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println("ReadAll with BOM detection and skipping", output)
	fmt.Println()
}

Output:

$ go run main.go
Input: [239 187 191 104 101 108 108 111]
ReadAll with BOM skipping [104 101 108 108 111]
Detected encoding: UTF8
ReadAll with BOM detection and skipping [104 101 108 108 111]

Input: [104 101 108 108 111]
ReadAll with BOM skipping [104 101 108 108 111]
Detected encoding: Unknown, no byte-order mark found
ReadAll with BOM detection and skipping [104 101 108 108 111]