Changeset 3150


Ignore:
Timestamp:
2002-06-17T15:25:05+12:00 (20 years ago)
Author:
jrm21
Message:

Text to/from the receptionist is encoded in unicode, so we convert to/from utf8 for mgpp.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/colservr/mgppsearch.cpp

    r2701 r3150  
    22 *
    33 * mgppsearch.cpp --
    4  * Copyright (C) 1999  The New Zealand Digital Library Project
     4 * Copyright (C) 1999-2002  The New Zealand Digital Library Project
    55 *
    66 * A component of the Greenstone digital library software
     
    3232#include "TextGet.h"
    3333#include "queryinfo.h"
    34 
     34#include "gsdlunicode.h"
    3535
    3636
     
    126126 
    127127  UCArray queryArray;
    128   SetCStr(queryArray, (queryparams.querystring.getcstr()));
    129  
     128  // greenstone gives us the query encoded in unicode. We want utf8.
     129  char* utf8querystring=to_utf8(queryparams.querystring).getcstr();
     130  SetCStr(queryArray, utf8querystring);
     131  delete utf8querystring;
     132
    130133  // create the mgpp query tree
    131134  QueryNode *queryTree = NULL;
     
    171174  for (int k=0; k<(int)queryResult.termFreqs.size(); k++) {
    172175    term.clear();
    173     term.termstr = GetCStr(queryResult.termFreqs[k].term);
     176    char* termfreq_cstr=GetCStr(queryResult.termFreqs[k].term);
     177    term.termstr = to_uni(termfreq_cstr);
     178    delete termfreq_cstr;
    174179    term.termstemstr = term.termstr;
     180    // we don't set term.utf8equivterms ?? - jrm21
    175181    term.termfreq = queryResult.termFreqs[k].termFreq;
    176182    queryresult.terms.push_back(term);
     
    178184   
    179185    for (int j=0; j<(int)queryResult.termFreqs[k].equivTerms.size(); j++) {
    180       queryresult.termvariants.insert(GetCStr(queryResult.termFreqs[k].equivTerms[j]));
     186      char* equivterm_cstr=GetCStr(queryResult.termFreqs[k].equivTerms[j]);
     187      queryresult.termvariants.insert(to_uni(equivterm_cstr));
     188      delete equivterm_cstr;
    181189    }
    182190
     
    222230
    223231  UCArrayClear(browseNode.term);
    224   SetCStr(browseNode.term, (queryparams.querystring.getcstr()));
     232  // greenstone gives us the query encoded in unicode. We want utf8.
     233  char* utf8querystring=to_utf8(queryparams.querystring).getcstr();
     234  SetCStr(browseNode.term, utf8querystring);
     235  delete utf8querystring;
    225236
    226237  // do the actual query
     
    231242  for (int i=0; i<(int)browseResult.termFreqs.size(); i++) {
    232243    term.clear();
    233     term.termstr = GetCStr(browseResult.termFreqs[i].term);
     244    char* term_cstr = GetCStr(browseResult.termFreqs[i].term);
     245    term.termstr = to_uni(term_cstr);
     246    delete term_cstr;
    234247    term.termstemstr = term.termstr;
    235248    term.termfreq = browseResult.termFreqs[i].termFreq;
     
    280293  // convert UCArray to text_t
    281294  output.clear();
    282   output = GetCStr(doctext);
     295  char* doctext_cstr = GetCStr(doctext);
     296  output = doctext_cstr;
     297  delete doctext_cstr;
    283298
    284299  // here need to remove the <Document>, <Section>, <Paragraph> tags
Note: See TracChangeset for help on using the changeset viewer.