function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DipikaDipika 

change ascii value to characters

is there any way to change ascii value to characters in apex class?

Navatar_DbSupNavatar_DbSup

Hi,

 

There is no any direct method exist to convert the ASCII to character. If you want to convert the ASCII to character you will have to create a map in which assign the ASCII value to the key value and the character to the value of the value.

 

 For example

 

Map<Integer, String> ASCIIMap = new Map<Integer, String> ();

 

                ASCIIMap.put(65,'A');

                ASCIIMap.put(66,'B');

                ASCIIMap.put(67,'C');

 

 

For the alternative you can use the JavaScript method on the VF page to convert the ASCII to Character.

For this follow the below link

 

http://salesforce-narasimha.blogspot.com/2011/09/retrive-ascii-code-for-character.html

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

 

DipikaDipika

Hello S jain,

                      My Problem is I want to make a vf page same as contact detail page on which all alphabets

                      should be there. But i dont want to add alphabets in list  1 by 1. As you mentioned solution by map

                      In this also i have to make entry one by one. so i want to change ascii values to characters by which i can      optimize my code. plz give me idea of that..................

Navatar_DbSupNavatar_DbSup

 Hi,


You can append the JavaScript between the lists where you want to put the field value. For the reference use below code

 


----- VF page --------

<apex:page controller="checkcontact">
<apex:form >
  <apex:pageBlock >
      <apex:pageBlockTable value="{!con}" var="conlist">
         
      <apex:column >
          <apex:facet name="header">Name</apex:facet>
          <script> var conname='{!conlist.name}'; if(conname=='Edna Frank') { document.write('hhhhh'); } else { document.write(conname); } </script>
            
      </apex:column>
      
             <apex:column >
          <apex:facet name="header">Email</apex:facet>
            {!conlist.Email}
      </apex:column>
      
      
      </apex:pageBlockTable>
  
  
  </apex:pageBlock>
  </apex:form>
</apex:page>

----- Apex controller --------

public class checkcontact
{
    public list<contact> con {get;set;}
    public boolean cc{get;set;}
    public checkcontact()
    {
        con=new list<contact>();
        cc=true;
        con=[select name,email from contact];
    }

}

 Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.