捐赠 | 广告 | 注册 | 发布 | 上传 | 关于我们    
  粤ICP备10103342号-1 DELPHI盒子 | 盒子文章 | 盒子问答悬赏 | 最新更新 | 盒子检索 | 下载中心 | 高级搜索    
  精品专区 | 繁體中文 | 奖励公告栏 | 直通车账号登陆 | 关闭GOOGLE广告 | 临时留言    
 
广告
评论:D2010下intraweb开发中文显示?之部分解决方案!
a200332 298441 2015/1/24 0:36:50
不是 ,直接 在页面 更换成  gb2312 的 编码格式不就是 可以中文了
m523882802 42151 2012/2/28 15:12:05
把UTF8ContentParser这个单元加入到你的DPR中,在需要使用的单元引用,应该就可以了!最近不怎么上盒子,抱歉各位盒友!
yxzzjg 42113 2012/2/7 18:45:27


这个问题也困扰了我很久,是不是真能解决?这个文件如何使用?
请不吝赐教!!!
yxzzjg 42112 2012/2/7 18:43:24
这个问题也困扰了我很久,是不是真能解决?这个文件如何使用?
请不吝赐教!!!
m523882802 41945 2011/11/5 10:39:34
不给力呀,没看给顶呀!第一次发,也不清楚怎么上传源码.等了半个月了总算通过了。下面贴出单元 
unit UTF8ContentParser;

interface

uses SysUtils,
  Classes,
  Masks,
  Contnrs,
  HTTPApp,
  ReqFiles,
  HTTPParse;

type

  { TUTF8ContentParser }

  TUTF8ContentParser = class(TContentParser)

  private

    FContentFields: TStrings;

  public

    destructor Destroy; override;

    function GetContentFields: TStrings; override;

    class function CanParse(AWebRequest: TWebRequest): Boolean; override;

  end;

implementation

uses WebConst,
  WebComp,
  BrkrConst,
  Windows;

{ TUTF8ContentParser }

class function TUTF8ContentParser.CanParse(AWebRequest: TWebRequest): Boolean;

begin

  Result := True;

end;

destructor TUTF8ContentParser.Destroy;

begin

  FContentFields.Free;

  inherited Destroy;

end;

procedure ExtractHeaderFields(Separators, WhiteSpace: TSysCharSet; Content:
  PAnsiChar;

  Strings: TStrings; Decode: Boolean; Encoding: TEncoding; StripQuotes: Boolean
    = False); forward;

function TUTF8ContentParser.GetContentFields: TStrings;

begin

  if FContentFields = nil then

  begin

    FContentFields := TStringList.Create;

    if WebRequest.ContentLength > 0 then

    begin

      ExtractHeaderFields(['&'], [], PAnsiChar(WebRequest.RawContent),
        FContentFields, True, TEncoding.UTF8);

    end;

  end;

  Result := FContentFields;

end;

// Version of HTTP.ExtractHeaderFields that supports encoding parameter

procedure ExtractHeaderFields(Separators, WhiteSpace: TSysCharSet; Content:
  PAnsiChar;

  Strings: TStrings; Decode: Boolean; Encoding: TEncoding; StripQuotes: Boolean
    = False);

var

  Head, Tail        : PAnsiChar;

  EOS, InQuote, LeadQuote: Boolean;

  QuoteChar         : AnsiChar;

  ExtractedField    : AnsiString;

  WhiteSpaceWithCRLF: TSysCharSet;

  SeparatorsWithCRLF: TSysCharSet;

  procedure AddString(const S: AnsiString);

  var

    LBytes          : TBytes;

    LString         : string;

  begin

    LBytes := BytesOf(S);

    LString := Encoding.GetString(LBytes);

    Strings.Add(LString);

  end;

  function DoStripQuotes(const S: AnsiString): AnsiString;

  var

    I          : Integer;

    InStripQuote    : Boolean;

    StripQuoteChar  : AnsiChar;

  begin

    Result := S;

    InStripQuote := False;

    StripQuoteChar := #0;

    if StripQuotes then

      for I := Length(Result) downto 1 do

        if CharInSet(Result[I], ['''', '"']) then

          if InStripQuote and (StripQuoteChar = Result[I]) then

          begin

          Delete(Result, I, 1);

          InStripQuote := False;

          end

          else if not InStripQuote then

          begin

          StripQuoteChar := Result[I];

          InStripQuote := True;

          Delete(Result, I, 1);

          end

  end;

begin

  if (Content = nil) or (Content^ = #0) then Exit;

  WhiteSpaceWithCRLF := WhiteSpace + [#13, #10];

  SeparatorsWithCRLF := Separators + [#0, #13, #10, '"'];

  Tail := Content;

  QuoteChar := #0;

  repeat

    while CharInSet(Tail^, WhiteSpaceWithCRLF) do Inc(Tail);

    Head := Tail;

    InQuote := False;

    LeadQuote := False;

    while True do

    begin

      while (InQuote and not CharInSet(Tail^, [#0, '"'])) or

      not CharInSet(Tail^, SeparatorsWithCRLF) do Inc(Tail);

      if Tail^ = '"' then

      begin

        if (QuoteChar <> #0) and (QuoteChar = Tail^) then

          QuoteChar := #0

        else

        begin

          LeadQuote := Head = Tail;

          QuoteChar := Tail^;

          if LeadQuote then Inc(Head);

        end;

        InQuote := QuoteChar <> #0;

        if InQuote then

          Inc(Tail)

        else Break;

      end else Break;

    end;

    if not LeadQuote and (Tail^ <> #0) and (Tail^ = '"') then

      Inc(Tail);

    EOS := Tail^ = #0;

    if Head^ <> #0 then

    begin

      SetString(ExtractedField, Head, Tail - Head);

      if Decode then

        AddString(HTTPDecode(AnsiString(DoStripQuotes(ExtractedField))))

      else AddString(DoStripQuotes(ExtractedField));

    end;

    Inc(Tail);

  until EOS;

end;

initialization

  RegisterContentParser(TUTF8ContentParser);

end.
第一页 上一页 下一页 最后页 有 5 条纪录 共1页 1 - 5
 用户名:
 密 码:
自动登陆(30天有效)
 
  DELPHI盒子版权所有 技术支持:深圳市麟瑞科技有限公司 1999-2024 V4.01 粤ICP备10103342号-1 更新RSS列表