Description

This function attempts to retrieve a file's character encoding.


Examples




https://hostname.example.com:2087/cpsess##########/json-api/cpanel?cpanel_jsonapi_user=user&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=Encoding&cpanel_jsonapi_func=guess_file&file=public_html/index.html



$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Retrieve encoding for
$get_encodings = $cpanel->api2(
    'Encoding', 'guess_file', 
		array (
			'file'				=> 'public_html/index.html',

    ) 
);

 



my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# Uninstall DomainKeys on example.com.
my $get_encodings = $cpliveapi->api2(
    'Encoding', 'guess_file'
		{
		'file' 				=> 'public_html/index.html'
		}
  );

 




cpapi2 --user=username Encoding guess_file file=public_html%2Findex.html



{
  "cpanelresult": {
    "apiversion": 2,
    "func": "guess_file",
    "data": [
      {
        "file": /home/user/public_html/index.html,
        "encoding": "us-ascii"
      }
    ],
    "event": {
      "result": 1
    },
    "module": "Encoding"
  }
}



Parameters

ParameterTypeDescriptionPossible valuesExample
filestring

Required

The file.

A valid file path, relative to the user's home directory.public_html/index.html

 

Returns

ReturnTypeDescriptionPossible valuesExample
encodingstringThe file's character encoding.Any cPanel-known character encoding.ansi_x3.110-1983
filestringThe file's path.An absolute file path./home/user/etc/example/passwd
reasonstring

A reason for failure.

This function only returns a reason value if there was an error. 


A string that describes the error.This is an error message.
resultBoolean

Whether the function succeeded.

 

  • 1 — The function succeeded.
  • 0 — The function failed.
1