Function Var2LChar() Foundation

Converts a variable to it's locale string representation.

Syntax
Var2LChar( <xValue> ) --> cString
Parameters
<xValue>
The parameter can have a value of any data type.
Return

The function returns the string representation of the passed value according to locale specific settings for the data type.

Description

Var2LChar() is used to convert values of any data type, be it simple or complex data types, to a locale string representation. It is the inverse function of LChar2Var(). Note, however, that LChar2Var() cannot convert the string representation of complex data types (Array, Code block, Object) to the original data type. If this is required, the functions Var2Bin() and Bin2Var() must be used.

Var2LChar() converts a code block to a string that is equivalent to PRG code. The string can be converted back to a code block using the macro operator. If you use this approach, you must make sure that the code block does not contain detached LOCAL variables. References to detached LOCALs are lost with Var2LChar().

Examples
Locale versus normal string representations
// The example demonstrates the difference between a normal 
// and a localized string representation of different 
// data types. 

#include "Nls.ch" 

PROCEDURE Main 
   LOCAL dDate   := Date() 
   LOCAL lOk     := .T. 
   LOCAL nNumber := 123.456 

   SET DATE TO GERMAN 
   SET CENTURY ON 

   SetLocale( NLS_SDECIMAL , "," ) 
   SetLocale( NLS_SYES     , "Y" ) 

   ? Var2Char ( dDate   )  // result: 20000426 
   ? Var2LChar( dDate   )  // result: 26.04.2000 

   ? Var2Char ( lOk     )  // result: T 
   ? Var2LChar( lOk     )  // result: Y 

   ? Var2Char ( nNumber )  // result: 123.456 
   ? Var2LChar( nNumber )  // result: 123,456 
RETURN 
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.