0
Function returning extra whitespace

/t5/coldfusion-discussions/function-returning-extra-whitespace/td-p/875530
Aug 11, 2008
Aug 11, 2008
Copy link to clipboard
Copied
I created a function to strip all non-numeric characters from
a string and format the phone number in a specific manner, but the
string that is returned has a <space> at the beginning of the
number every time. Using TRIM() does not need to remove the extra
whitespace. Any ideas?
TOPICS
Getting started
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Engaged
,
/t5/coldfusion-discussions/function-returning-extra-whitespace/m-p/875531#M80763
Aug 11, 2008
Aug 11, 2008
Copy link to clipboard
Copied
I don't see you using trim anywhere? Also, what is the number
you are passing in your test?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Engaged
,
/t5/coldfusion-discussions/function-returning-extra-whitespace/m-p/875532#M80764
Aug 11, 2008
Aug 11, 2008
Copy link to clipboard
Copied
add output="false" to your cffunction declaration
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Engaged
,
/t5/coldfusion-discussions/function-returning-extra-whitespace/m-p/875533#M80765
Aug 11, 2008
Aug 11, 2008
Copy link to clipboard
Copied
Sorry I didn't notice that straight away but I have been
putting that in by default for so long that I forgot about that
behaviour!
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

Guest
AUTHOR
/t5/coldfusion-discussions/function-returning-extra-whitespace/m-p/875534#M80766
Aug 11, 2008
Aug 11, 2008
Copy link to clipboard
Copied
I had used TRIM() in these 2 scenarios:
<cfreturn trim(tmpPhone)>
and when calling the function:
#TRIM(FormatPhone(varaible))#
The value of "variable" may be "123-456-7890"
<cfreturn trim(tmpPhone)>
and when calling the function:
#TRIM(FormatPhone(varaible))#
The value of "variable" may be "123-456-7890"
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

Guest
AUTHOR
/t5/coldfusion-discussions/function-returning-extra-whitespace/m-p/875535#M80767
Aug 11, 2008
Aug 11, 2008
Copy link to clipboard
Copied
I guess setting output="no" worked even though I swear I
tried that already... thanks!
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Engaged
,
LATEST
/t5/coldfusion-discussions/function-returning-extra-whitespace/m-p/875536#M80768
Aug 11, 2008
Aug 11, 2008
Copy link to clipboard
Copied
Basically if you do not put output="false" then it will leave
the white space for the the cftags it has removed to leave the
result. It is a crap behaviour and is there because functions can
output text without having to return it. It is a crap behaviour IMO
however some people want to use it that way.
I wish cffunction had output="false" as default instead of the other way round, but that would be beginning of a long wish-list!
I wish cffunction had output="false" as default instead of the other way round, but that would be beginning of a long wish-list!
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

