跳到主內容

//ERDDAP/com.cohort.util/ScriptString2/encodeMatlabNameSafe

encodeMatlabNameSafe

[JVM]
open fun encodeMatlabNameSafe(s: String): String

This is like encodeFileNameSafe, but further restricts the name to

  • first character must be A-Z, a-z.
  • subsequent characters must be A-Z, a-z, _, 0-9.

'x' and non-safe characters are CONVERTED to 'x' plus their 2 lowercase hexadecimalDigit number or "xx" + their 4 hexadecimalDigit number. See posix fully portable file names at https://en.wikipedia.org/wiki/Filename . When the encoding is more than 25 characters, this stops encoding and adds "xh" and the hash code for the entire original string, so the result will always be less than ~41 characters. This meets MatLab restrictions: https://www.mathworks.com/help/matlab/ref/matlab.lang.makevalidname.html

THIS WON'T BE CHANGED. FILE NAMES CREATED FOR EDDGridFromFile and EDDTableFromFile DEPEND ON SAME ENCODING OVER TIME.

Return

s with all of the non-variableNameSafe characters changed. If s is null, this returns "x_1". If s is "", this returns "x_0".

Parameters

JVM

s