def encodeUcs2(text):
    """ UCS2 text encoding algorithm
    
    Encodes the specified text string into UCS2-encoded bytes.
    
    :param text: the text string to encode
    
    :return: A bytearray containing the string encoded in UCS2 encoding
    :rtype: bytearray
    """
    result = bytearray()
    for b in map(ord, text):
        result.append(b >> 8)
        result.append(b & 0xFF)
    return result
UCS2 text encoding algorithm
    
    Encodes the specified text string into UCS2-encoded bytes.
    
    :param text: the text string to encode
    
    :return: A bytearray containing the string encoded in UCS2 encoding
    :rtype: bytearray