Is there any function in Apex which could emulate functionality of the CASESAFEID() formula function? I'm trying to get 18-char Id variant from the standard one.
Per the Apex docs on primitive datatypes, "Note that if you set [an] ID to a 15-character value, Apex automatically converts the value to its 18-character representation." So it should be enough to assign your 15 character id to an ID-typed variable, and then back to a string, like so:
Remember that assigning an invalid id string to an ID-typed variable will throw an exception; if there's any chance that your 15 character value may not be a valid id, wrap the assignment in a try/catch block.