Description

This function converts a buffer from one encoding language to another.

Examples 




https://hostname.example.com:2083/cpsess##########/execute/Fileman/transcode?from_charset=utf-8&to_charset=us-ascii&content="hi"&discard_illegal=1&transliterate=1

 



$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Convert file from UTF-8 to ASCII.
$convert_file_encoding = $cpanel->uapi(
    'Fileman', 'transcode',
		array(
		'from_charset'		=> 'UTF-8',
		'to_charset'		=> 'ASCII',
		'content'			=> '"hi"',
		'discard_illegal'	=> '0',
		'transliterate'		=> '0',
  )
);

 



my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# Convert file from UTF-8 to ASCII.
my $ convert_file_encoding = $cpliveapi->uapi(
 'Fileman', 'transcode',
		{
		'from_charset'		=> 'UTF-8',
		'to_charset'		=> 'ASCII',
		'content'			=> '"hi"',
		'discard_illegal'	=> '0',
		'transliterate'		=> '0',
		}
 );

 



<!-- Get a hash of all the data, then display the charset value. -->
[% data = execute( 'Fileman', 'upload_files' {'from_charset' => 'UTF-8', 'to_charset' => 'ASCII', 'content' => '"hi", 'discard_illegal' => '1', 'translitertate' => '0',} ); %]
[% FOREACH q = data.path %]
     <p>
         [% q %]
     </p>
[% END %]
 
<!-- Get only a hash of the data. -->
[% execute('Fileman', 'upload_files' {'from_charset' => 'UTF-8', 'to_charset' => 'ASCII', 'content' => '"hi", 'discard_illegal' => '1', 'translitertate' => '0',}  ).data.path %]

 



uapi --user=username Fileman transcode from_charset=utf-8 to_charset=us-ascii content=\"hi\" discard_illegal=1 transliterate=1



{  
   "messages":null,
   "errors":null,
   "status":1,
   "metadata":{  

  },
  "data": {
    "from_charset": "utf-8",
    "to_charset": "utf-8",
    "path": "/home/username/public_html/example.html"
  }
}



Parameters

ParametersTypeDescriptionPossible valuesExample
contentstring

Required

The file's contents.

A string value."hi"
from_charsetstring

The file's current character set encoding.

 

Any cPanel-supported character set encoding.

UTF-8

 
to_charsetstring

The character set encoding in which to encode the file.

Any cPanel-supported character set encoding.

ASCII

 
discard_illegalBooleanWhether to discard any characters that do not transcode correctly.1
transliterateBooleanWhether to transcode invaid characters to valid characters in the new character set encoding.0

Returns

ReturnTypeDescriptionPossible valuesExample
contentstringThe file content.A string value."hi"
charsetstring

The file's new character set.

A cPanel-supported character set encoding.

ASCII