Save internal encoding
335252
private function saveEncoding()
    {
        if (version_compare(PHP_VERSION, '7.2.0') >= 0) {
            return;
        }

        $iniDirective = 'mbstring' . '.func_overload'; // deprecated in PHP 7.2

        if (ini_get($iniDirective) & 2) {
            $this->encoding = mb_internal_encoding();

            mb_internal_encoding('iso-8859-1');
        }
    }
1131456
function encode(data) {
  $.checkArgument(data instanceof Array, 'Must be Array');
  var base32 = '';
  for (var i=0; i<data.length; i++) {
    var value = data[i];
    $.checkArgument(0 <= value && value < 32, 'Non-base32, value ' + value);
    base32 += CHARSET[value];
  }
  return base32;
}
122007
def saveFileTo(self, buf, encoding):
        
        if buf is None: buf__o = None
        else: buf__o = buf._o
        ret = libxml2mod.xmlSaveFileTo(buf__o, self._o, encoding)
        return ret
694678
def dict_encode(in_dict):
    """"""
    if _IS_PY2:
        out_dict = {}
        for k, v in list(in_dict.items()):
            if isinstance(v, unicode):
                v = v.encode('utf8')
            elif isinstance(v, str):
                # Must be encoded in UTF-8
                v.decode('utf8')
            out_dict[k] = v
        return out_dict
    else:
        raise NotImplementedError
166712
def edit_encoding(cls, parent):
        
        dlg = cls(parent)
        if dlg.exec_() == dlg.Accepted:
            settings = Cache()
            settings.preferred_encodings = dlg.get_preferred_encodings()
            return True
        return False
181002
private String encodeUri( String uri )
	{
		StringBuilder newUri = new StringBuilder();
		StringTokenizer st = new StringTokenizer( uri, "/ ", true );
		while ( st.hasMoreTokens())
		{
			String tok = st.nextToken();
			if ( tok.equals( "/" )) {
				newUri.append('/');
			} else if ( tok.equals( " " )) {
				newUri.append("%20");
			} else {
				try {
					newUri.append(URLEncoder.encode( tok, "UTF-8" ));
				} catch ( UnsupportedEncodingException uee ) { // NOPMD - imported code
					// imported code
				}
			}
		}
		return newUri.toString();
	}
1124070
void saveScript() throws IOException {
		// We'll always try to read it in with the default next time its loaded
		this.charset = ExtensionScript.DEFAULT_CHARSET;
		try ( BufferedWriter bw = Files.newBufferedWriter(file.toPath(), charset)) {
			bw.append(getContents());
		}
		this.lastModified = file.lastModified();
	}
1003401
def encode(cls, line):
        """"""
        if not line.encoded:
            encoding = getattr(line, 'encoding_param', None)
            if encoding and encoding.upper() == cls.base64string:
                line.value = b64encode(line.value).decode('utf-8')
            else:
                line.value = backslashEscape(str_(line.value))
            line.encoded = True
94966
public static void saveAsFile(String data, String charset, String addr) throws IOException {
        charset = StringUtils.isEmpty(charset) ? "UTF8" : charset;
        saveAsFile(data.getBytes(charset), addr);
    }
1066069
private static String getEncodingToUse(String encoding)
    {
        //get encoding
        String updatedEncoding=encoding;
        if(updatedEncoding==null)
        {
            updatedEncoding=IOHelper.getDefaultEncoding();
        }
        
        return updatedEncoding;
    }
779831
def _set_file_encoding_utf8(filename):
    """"""
    with open(filename, 'r+') as f:
        content = f.read()
        f.seek(0, 0)
        f.write("# -*- coding: utf-8 -*-\n" + content)
1183414
function __encode_utf8(text) {

        // Fill buffer with UTF-8
        for (var i=0; i<text.length; i++) {
            var codepoint = text.charCodeAt(i);
            __append_utf8(codepoint);
        }

        // Flush buffer
        if (length > 0) {
            var out_buffer = buffer.subarray(0, length);
            length = 0;
            return out_buffer;
        }

    }
954391
public static void encode(CharSequence in, Appendable out) throws IOException{
		encode(in, UTF_8, out);
	}
522677
def encode(value, encoding='utf-8', encoding_errors='strict'):
    
    if isinstance(value, bytes):
        return value
    if not isinstance(value, basestring):
        value = str(value)
    if isinstance(value, unicode):
        value = value.encode(encoding, encoding_errors)
    return value
1361905
def set_file_encoding(self, path, encoding):
        
        try:
            map = json.loads(self._settings.value('cachedFileEncodings'))
        except TypeError:
            map = {}
        map[path] = encoding
        self._settings.setValue('cachedFileEncodings', json.dumps(map))
1208060
static function internalCharset()
    {
        $realCharset =& $GLOBALS['eZTextCodecInternalCharsetReal'];
        if ( !isset( $realCharset ) )
        {
            if ( !isset( $GLOBALS['eZTextCodecInternalCharset'] ) )
            {
                $i18n = eZINI::instance( 'i18n.ini', '', false );
                $charsetCode = $i18n->variable( 'CharacterSettings', 'Charset' );
            }
            else
                $charsetCode = $GLOBALS['eZTextCodecInternalCharset'];
            $realCharset = eZCharsetInfo::realCharsetCode( $charsetCode );
        }
        return $realCharset;
    }
988075
def save(self, name):
        
        self.finalize()
        with open(name, 'wb+') as f:
            if six.PY3:
                f.write(self.fileobj.getbuffer())
            else:
                f.write(self.fileobj.getvalue().encode('utf-8'))