package jx

import (
	stdbase64 

	
)

// Base64 encodes data as standard base64 encoded string.
//
// Same as encoding/json, base64.StdEncoding or RFC 4648.
func ( *Writer) ( []byte) bool {
	if  == nil {
		return .Null()
	}

	if .byte('"') {
		return true
	}

	 := base64.StdEncoding.EncodedLen(len())
	switch {
	case .stream == nil || len(.Buf)+ <= cap(.Buf):
		 := len(.Buf)
		.Buf = append(.Buf, make([]byte, )...)
		base64.StdEncoding.Encode(.Buf[:], )
	default:
		 := .stream

		var  bool
		.Buf,  = .flush(.Buf)
		if  {
			return true
		}
		 := stdbase64.NewEncoder(stdbase64.StdEncoding, .writer)
		if ,  := .Write();  != nil {
			.setError()
			return true
		}
		if  := .Close();  != nil {
			.setError()
			return true
		}
	}

	return .byte('"')
}