Results 1 to 5 of 5
  1. #1
    drift is offline Member
    Join Date
    Oct 2010
    Posts
    3
    Rep Power
    0

    Default working with unicode strings

    Hi,

    I retrieved a list from the datastore and the list was stored as unicode string.

    So, while displaying, the list that looks like [10,11] is displayed as [1, 0, ,, , 1, 1] with extra commas.

    Can someone please help as to how to fix this?

    Thanks in advance!

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default

    Can you show us yor code?
    Without that we have absolutely no idea what's going on.
    Even better, something that is short and simple and compiles and shows the problem.

  3. #3
    drift is offline Member
    Join Date
    Oct 2010
    Posts
    3
    Rep Power
    0

    Default

    Here's a simple version of my code :

    Java Code:
    StringBuffer intersectionEdges ;	//to store the common edges
    		
    EntityManager em;
    	
    		
    //Retrieve all the source and its adjacent Nodes for the graph with graph id =1
    Query query = em.createQuery("SELECT source,adjacentNodes FROM Node x WHERE graphId=1");
    				
    intersectionEdges = new StringBuffer();
    		
    List<Object[]> results = (List<Object[]>) query.getResultList();
    
    //iterate through the results
    for (Object[] result : results) {	
    			
        g1AdjacentNodes = (List<Long>) result[1]; //retrieve the adjacent nodes 
        intersectionEdges.append(g1AdjacentNodes);		
    
    }
    The intersectionEdges is the StringBuffer which is going to be displayed.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default

    What is the column type of adjacentNodes?
    How is this list of Longs stored in the database?
    How does it convert from whatever type that column is to the List of Longs?
    Have you debugged to see what g1AdjacentNodes contains after the assigning from the result[1]?

  5. #5
    drift is offline Member
    Join Date
    Oct 2010
    Posts
    3
    Rep Power
    0

    Default

    Ok, I found a way to display. Instead of just appending the list adjacentNodes to the StringBuffer, I iterated through the list and then appended each value to the StringBuffer . That makes my output display more easy to read.

Similar Threads

  1. String to Unicode
    By minime12358 in forum New To Java
    Replies: 5
    Last Post: 09-07-2010, 12:08 PM
  2. Unicode(UTF-8) to PDF
    By karasatishkumar in forum Advanced Java
    Replies: 0
    Last Post: 03-24-2010, 10:59 AM
  3. SWT 2D Unicode Example
    By Java Tip in forum SWT
    Replies: 0
    Last Post: 06-28-2008, 09:21 PM
  4. Replies: 8
    Last Post: 05-28-2008, 07:00 AM
  5. Unicode problem
    By rovshanb in forum JDBC
    Replies: 0
    Last Post: 02-14-2008, 06:41 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •