<html>
<head>
    <base href="https://wiki.asterisk.org/wiki">
            <link rel="stylesheet" href="/wiki/s/en/2176/25/9/_/styles/combined.css?spaceKey=AST&amp;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/~lmadsen">Leif Madsen</a>
    </h4>
        <div id="versionComment">
        <b>Comment:</b>
        Simple formatting change of dialplan examples to match that documented in ATDG<br />
    </div>
        <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" >[default] <br>exten =&gt; 1000,1,Set(DEST=${DB(egg/salad)}) <br></td></tr>
            <tr><td class="diff-unchanged" >    same =&gt; n,Dial(${DEST},15) <br></td></tr>
            <tr><td class="diff-unchanged" >{noformat} <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{noformat} <br>exten =&gt; 1000,1,Set(DEST=${DB(egg/salad)}) <br></td></tr>
            <tr><td class="diff-unchanged" >    same =&gt; n,Dial(${dest},15) <br></td></tr>
            <tr><td class="diff-unchanged" >{noformat} <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{noformat} <br>exten =&gt; 1000,1,Set(DeSt=${DB(egg/salad)}) <br></td></tr>
            <tr><td class="diff-unchanged" >    same =&gt; n,Dial(${dEsT},15) <br></td></tr>
            <tr><td class="diff-unchanged" >{noformat} <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{noformat} <br>exten =&gt; 1000,Set(sip_codec=g729) <br></td></tr>
            <tr><td class="diff-unchanged" >    same =&gt; n,Dial(SIP/1000,15) <br></td></tr>
            <tr><td class="diff-unchanged" >{noformat} <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{noformat} <br>exten =&gt; 1000,Set(SIP_CODEc=g729) <br></td></tr>
            <tr><td class="diff-unchanged" >    same =&gt; n,Dial(SIP/1000,15) <br></td></tr>
            <tr><td class="diff-unchanged" >{noformat} <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{noformat} <br>exten =&gt; 1000,Set(SIP_CODEc=g729) <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">    same =&gt; n,NoOp(${SIP_CODEC}) <br></td></tr>
            <tr><td class="diff-changed-lines" >same =&gt; <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">n,NoOp(${SIP_CODEC})</span> <span class="diff-added-words"style="background-color: #dfd;">n,Dial(SIP/1000,15)</span> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">same =&gt; n,Dial(SIP/1000,15) <br></td></tr>
            <tr><td class="diff-unchanged" >{noformat} <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<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>This includes versions</p>

<ul>
        <li>Asterisk 1.0.X</li>
        <li>Asterisk 1.2.X</li>
        <li>Asterisk 1.4.X</li>
        <li>Asterisk 1.6.0.X</li>
        <li>Asterisk 1.6.1.X</li>
        <li>Asterisk 1.6.2.X</li>
        <li>Asterisk 1.8.X</li>
        <li>Asterisk 10.X</li>
        <li>Asterisk 11.X</li>
</ul>


<p>These versions of Asterisk follow these three 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>Built-in 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 =&gt; 1000,1,Set(DEST=${DB(egg/salad)})
    same =&gt; 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 =&gt; 1000,1,Set(DEST=${DB(egg/salad)})
    same =&gt; 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 =&gt; 1000,1,Set(DeSt=${DB(egg/salad)})
    same =&gt; 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 =&gt; _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 =&gt; _X.,1,Dial(SIP/${exten})
</pre>
</div></div>

<p>The lowercase <tt>exten</tt> variable would evaluate to an empty string since no previous value was set for <tt>exten</tt>.</p>

<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 =&gt; 1000,Set(SIP_CODEC=g729)
same =&gt; 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 =&gt; 1000,Set(sip_codec=g729)
    same =&gt; 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 =&gt; 1000,Set(SIP_CODEc=g729)
    same =&gt; 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 <tt>NoOp</tt> in the dialplan:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>exten =&gt; 1000,Set(SIP_CODEc=g729)
    same =&gt; n,NoOp(${SIP_CODEC})
    same =&gt; 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 be evaluated consistently. E-mails were sent to the <a href="http://lists.digium.com/pipermail/asterisk-dev/2012-October/057056.html" class="external-link" rel="nofollow">Asterisk-developers</a> and <a href="http://lists.digium.com/pipermail/asterisk-users/2012-October/275033.html" class="external-link" rel="nofollow">Asterisk-users</a> 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>

<p>For those who are upgrading to Asterisk 12 from a previous version, be absolutely sure that your variables are used consistently throughout your dialplan.</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=7&originalVersion=6">View Changes</a>
                |
        <a href="https://wiki.asterisk.org/wiki/display/AST/Case+Sensitivity?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>