<html>
<head>
<base href="https://wiki.asterisk.org/wiki">
<link rel="stylesheet" href="/wiki/s/en/2176/25/9/_/styles/combined.css?spaceKey=AST&forWysiwyg=true" type="text/css">
</head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
<h2><a href="https://wiki.asterisk.org/wiki/display/AST/Case+Sensitivity">Case Sensitivity</a></h2>
<h4>Page <b>edited</b> by <a href="https://wiki.asterisk.org/wiki/display/~mmichelson">Mark Michelson</a>
</h4>
<br/>
<h4>Changes (3)</h4>
<div id="page-diffs">
<table class="diff" cellpadding="0" cellspacing="0">
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" >{noformat} <br> <br></td></tr>
<tr><td class="diff-changed-lines" >When the user checks the verbose logs, he sees that the second priority has evaluated {{SIP_CODEC}} to be "g729". This is because the evaluation in the dialplan was done case-insensitively. <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">This can be confusing</span> <br></td></tr>
<tr><td class="diff-unchanged" > <br>h1. Asterisk 12 and above <br> <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">Pending <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">Due to potential confusion stemming from the policy, for Asterisk 12, it was proposed that variables should evaluated consistently. E-mails were sent to the Asterisk-developers and Asterisk-users lists about whether variables should be evaluated case-sensitively or case-insensitively. The majority opinion swayed towards case-sensitive evaluation. Thus in Asterisk 12, all variable evaluation, whether done in the dialplan or internally, will be case-sensitive. <br></td></tr>
</table>
</div> <h4>Full Content</h4>
<div class="notificationGreySide">
<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>This page is a work in progress. Please refrain from making comments until this warning is removed</td></tr></table></div>
<p>Case sensitivity of channel variables in Asterisk is dependent on the version of Asterisk in use.</p>
<h1><a name="CaseSensitivity-VersionspriortoAsterisk12"></a>Versions prior to Asterisk 12</h1>
<p>These versions of Asterisk follow these two rules:</p>
<ul>
        <li>Variables evaluated in the dialplan are <b>case-insensitive</b></li>
        <li>Variables evaluated within Asterisk's internals are <b>case-sensitive</b></li>
        <li>Builtin variables are <b>case-sensitive</b></li>
</ul>
<p>This is best illustrated through the following examples</p>
<h3><a name="CaseSensitivity-Example1%3AAusersetvariable"></a>Example 1: A user-set variable</h3>
<p>In this example, the user retrieves a value from the AstDB and then uses it as the destination for a <tt>Dial</tt> command.</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>[default]
exten => 1000,1,Set(DEST=...)
same => n,Dial(${DEST},15)
</pre>
</div></div>
<p>Since the <tt>DEST</tt> variable is set and evaluated in the dialplan, its evaluation is case-insensitive. Thus the following would be equivalent:</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>exten => 1000,1,Set(DEST=...)
same => n,Dial(${dest},15)
</pre>
</div></div>
<p>As would this:</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>exten => 1000,1,Set(DeSt=...)
same => n,Dial(${dEsT},15)
</pre>
</div></div>
<h3><a name="CaseSensitivity-Example2%3AUsingabuiltinvariable"></a>Example 2: Using a built-in variable</h3>
<p>In this example, the user wishes to use a built-in variable in order to determine the destination for a call.</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>exten => _X.,1,Dial(SIP/${EXTEN})
</pre>
</div></div>
<p>Since the variable <tt>EXTEN</tt> is a built-in variable, the following would <b>not</b> be equivalent:</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>exten => _X.,1,Dial(SIP/${exten})
</pre>
</div></div>
<h3><a name="CaseSensitivity-Example3%3AAvariableusedinternallybyAsterisk"></a>Example 3: A variable used internally by Asterisk</h3>
<p>In this example, the user wishes to suggest to the SIP channel driver what codec to use on the call.</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>exten => 1000,Set(SIP_CODEC=g729)
same => n,Dial(SIP/1000,15)
</pre>
</div></div>
<p><tt>SIP_CODEC</tt> is set in the dialplan, but it gets evaluated inside of Asterisk, so the evaluation is case-sensitive. Thus the following dialplan would not be equivalent:</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>exten => 1000,Set(sip_codec=g729)
same => n,Dial(SIP/1000,15)
</pre>
</div></div>
<p>This can lead to some rather confusing situations. Consider that a user wrote the following dialplan. He intended to set the variable <tt>SIP_CODEC</tt> but instead made a typo:</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>exten => 1000,Set(SIP_CODEc=g729)
same => n,Dial(SIP/1000,15)
</pre>
</div></div>
<p>As has already been discussed, this is not equivalent to using <tt>SIP_CODEC</tt>. The user looks over his dialplan and does not notice the typo. As a way of debugging, he decides to place a NoOp in the dialplan:</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>exten => 1000,Set(SIP_CODEc=g729)
same => n,NoOp(${SIP_CODEC})
same => n,Dial(SIP/1000,15)
</pre>
</div></div>
<p>When the user checks the verbose logs, he sees that the second priority has evaluated <tt>SIP_CODEC</tt> to be "g729". This is because the evaluation in the dialplan was done case-insensitively.</p>
<h1><a name="CaseSensitivity-Asterisk12andabove"></a>Asterisk 12 and above</h1>
<p>Due to potential confusion stemming from the policy, for Asterisk 12, it was proposed that variables should evaluated consistently. E-mails were sent to the Asterisk-developers and Asterisk-users lists about whether variables should be evaluated case-sensitively or case-insensitively. The majority opinion swayed towards case-sensitive evaluation. Thus in Asterisk 12, all variable evaluation, whether done in the dialplan or internally, will be case-sensitive.</p>
</div>
<div id="commentsSection" class="wiki-content pageSection">
<div style="float: right;" class="grey">
<a href="https://wiki.asterisk.org/wiki/users/removespacenotification.action?spaceKey=AST">Stop watching space</a>
<span style="padding: 0px 5px;">|</span>
<a href="https://wiki.asterisk.org/wiki/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
<a href="https://wiki.asterisk.org/wiki/display/AST/Case+Sensitivity">View Online</a>
|
<a href="https://wiki.asterisk.org/wiki/pages/diffpagesbyversion.action?pageId=21463732&revisedVersion=2&originalVersion=1">View Changes</a>
|
<a href="https://wiki.asterisk.org/wiki/display/AST/Case+Sensitivity?showComments=true&showCommentArea=true#addcomment">Add Comment</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>