Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

euphoria
case conversion
communitycreator

How to perform case conversion in Euphoria

NDUKWE CHIDERA K.

Overview

Case conversion is a common function amongst all programing languages. In the same vein, Euphoria language has provision for converting an atom or sequence from uppercase to lowercase and vice versa.

To do this in Euphoria, we use two functions:

  • The lower() function
  • The upper() function

The lower() function will convert an uppercase sequence or atom strings to lower case.

The upper() function will convert an uppercase sequence or atom strings to lower case.

Syntax

lowwer(value_to_converted)
upper(value_to_converted)

Parameter

This function takes the parameter, value_to_converted, which represents the string sequence.

Note: To use this function, we have to import the text.e file from Euphoria’s core standard library into our program.

include std/text.e

--declare some sequence variable
sequence conv1, conv2, increase, decrease

--assign values
conv1  = "PINgING"  
conv2 = "changing"
-- carry out case casting using lower and upper methods
decrease = lower(conv1)
increase = upper(conv2)
--print outcome to output
printf(1,"\"PINgING\" To lowercase: %s",{ decrease})
printf(1,"\n\"changing\" To uppercase: %s",{increase})
Case conversion in Euphoria

Explanation

  • Line 1: We include the text file.
  • Line 4: We declare the sequence to be used in the program.
  • Lines 7–8: We assign values to already declared sequences.
  • Lines 10–11: We call the lower() and upper() method on variables conv1 and conv2, and save the output in decrease and increase respectively.
  • Lines 13–14: We use printf to print the output.

RELATED TAGS

euphoria
case conversion
communitycreator
RELATED COURSES

View all Courses

Keep Exploring